Skip to content

Refactor: Break out stream auth handling from transport layer - #2763

Merged
hampuslavin merged 19 commits into
serverpod:mainfrom
hampuslavin:hl_move_stream_auth_to_endoint_dispatch
Sep 27, 2024
Merged

hampuslavin merged 19 commits into
serverpod:mainfrom
hampuslavin:hl_move_stream_auth_to_endoint_dispatch

Conversation

@hampuslavin

@hampuslavin hampuslavin commented Sep 20, 2024 •

Copy link
Copy Markdown
Contributor

Description

Breaks out the revoked authentication handling of streams from the transport layer. This enables the tests to leverage the same logic and ensures the behavior is authentic in the test environment. This expanded a bit in scope when we realized it's best to refactor out the entire _MethodStreamManager so that the test tools can use it as well.

Fixes #2739.

Changes

  • Refactors the private _MethodStreamManager into a public one that is uncoupled from Web Sockets
    • 💡 Although it has to be exported to be used by the serverpod_test package, it's tagged as @internal (which gives linter warnings) plus a comment that states it should only be used in Serverpod packages.
  • Moves revoked authentication handling into a private _RevokedAuthenticationHandler to make the code more readable
  • Creates a small TestStreamManager that glues the generated test code together with the new MethodStreamManager

Pre-launch Checklist

  • I read the Contribute page and followed the process outlined there for submitting PRs.
  • This update contains only one single feature or bug fix and nothing else. (If you are submitting multiple fixes, please make multiple PRs.)
  • I read and followed the Dart Style Guide and formatted the code with dart format.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///), and made sure that the documentation follows the same style as other Serverpod documentation. I checked spelling and grammar.
  • I added new tests to check the change I am making.
  • All existing and new tests are passing.
  • Any breaking changes are documented below.

@hampuslavin
hampuslavin force-pushed the hl_move_stream_auth_to_endoint_dispatch branch 2 times, most recently from 9ad723e to 1f21dd6 Compare September 25, 2024 11:29
@hampuslavin
hampuslavin marked this pull request as ready for review September 25, 2024 11:31
@hampuslavin
hampuslavin force-pushed the hl_move_stream_auth_to_endoint_dispatch branch 3 times, most recently from b29d11c to 69a8437 Compare September 25, 2024 12:41

@SandPod SandPod left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!
Thanks for separating the stream manager from the protocol layer. Makes total sense 👍

I have a couple of questions and suggestions for you.

Comment thread packages/serverpod/lib/server.dart Resolved
@hampuslavin
hampuslavin force-pushed the hl_move_stream_auth_to_endoint_dispatch branch from 26d3653 to 9463b55 Compare September 26, 2024 12:31
@hampuslavin
hampuslavin force-pushed the hl_move_stream_auth_to_endoint_dispatch branch from a5e4316 to 19b8d80 Compare September 26, 2024 13:49

@SandPod SandPod left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much improved code and I love how small the TestStreamManager is now thanks to this refactor.

A couple of last questions for you.

@SandPod SandPod left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 👍

@hampuslavin
hampuslavin merged commit 8aad562 into serverpod:main Sep 27, 2024
@hampuslavin
hampuslavin deleted the hl_move_stream_auth_to_endoint_dispatch branch September 27, 2024 08:41
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move revoked authentication logic to endpoint dispatch for method streams.

2 participants