Skip to content

Move revoked authentication logic to endpoint dispatch for method streams. #2739

Closed

Description

@SandPod

Is your feature request related to a problem? Please describe.
The logic to close streams where authentication has been revoked is currently implemented in the WebSocket layer.

Place of some part of the implementation:

var authenticationIsRequired =
methodStreamCallContext.endpoint.requireLogin ||
methodStreamCallContext.endpoint.requiredScopes.isNotEmpty;
_AuthenticationContext? authenticationContext;
if (authenticationIsRequired) {
var authenticationInfo = await session.authenticated;
if (authenticationInfo == null) {
throw StateError(
'Authentication was required and passed but no authentication info could be retrieved.',
);
}
authenticationContext = _AuthenticationContext(
methodStreamCallContext.endpoint.requiredScopes,
authenticationInfo,
);
}

This creates a difference when replicating authentication revoked behavior in the test framework that is being developed.
Describe the solution you'd like
By moving the closing of streams that have their authentication revoked into the endpoint dispatch, this logic can be shared for all code paths that rely on a stream.

This also ensures that the framework behaves the same regardless of transport protocol.

Additional context
This issues is connected to the work being done with the new test framework: #2494

Activity

  1. added
    area: authentication
    on Sep 11, 2024
  2. added
    enhancement
    on Sep 11, 2024
  3. self-assigned this
    on Sep 26, 2024
  4. moved this from Now 🔥 to Done 🚀 in Serverpod Frameworkson Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area: authenticationenhancement

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions