Repository navigation
Conversation
SignalR authenticates a connection once, when it opens, so a logged out session or a revoked, expired or deactivated API token could keep using a connection that was already open. Revocations are now announced on Redis and the instance holding an affected UserHub connection closes it right away: deleted and expired sessions, deactivated or deleted accounts, and deleted API tokens. An edited token makes its connections read it again on their next call, so the hub uses its current permissions, pause state and control limits instead of the ones from connect time. As a fallback for a lost message or a token that reaches its expiry, a hub filter re-checks a connection against the database when it opens and at most once per minute while it is making calls.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 53 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this change?
SignalR authenticates a connection once, when it opens. A logged out session, or a revoked, expired or deactivated API token, could therefore keep using a
UserHubconnection that was already open, including sending control commands.api-token-update:{id}channel.HubRevalidationOptions.Interval). This covers a lost Redis message and tokens that reachValidUntil, which nothing announces. An idle connection is never queried.New pieces:
HubConnectionTracker(per-instance registry of open authenticated hub connections),RevalidateAuthenticationHubFilter, and thesession-revoked/user-auth-revokedRedis channels.SessionServicepublishes on every delete.This touches authentication and device control (the SignalR control path).
Not covered here:
How was it tested?
New integration tests in
API.IntegrationTests/Tests/SignalRUserHubTests.cs, using real WebSocket hub connections against the test server:Logout_ClosesTheSessionsOpenConnection,DeletingAnApiToken_ClosesItsOpenConnection,DeactivatingAnAccount_ClosesItsSessionAndApiTokenConnections. The first two also check that another connection stays open.Invoke_AfterSessionDeleted_FailsAndClosesConnection,Invoke_AfterAccountDeactivated_WithTheSessionLeftBehind_FailsAndClosesConnection,Invoke_AfterApiTokenDeleted_FailsAndClosesConnection,Invoke_AfterApiTokenExpired_FailsAndClosesConnection,Invoke_AfterApiTokenOwnerDeactivated_FailsAndClosesConnection.Invoke_ManyCallsInARow_ChecksTheApiTokenOncePerInterval.Invoke_WithValidSession_KeepsWorking,Invoke_WithValidApiToken_KeepsWorking.API integration tests pass locally on this branch (240/240). Not tested against a multi-instance deployment or in a browser.
Checklist