Repository navigation
Conversation
A live control socket was authenticated once, when it opened. When its API token changed, the gateway refreshed the pause state and limits but never checked that the token could still control, so a token that lost shockers.use kept working. Expiry was only noticed if some token change happened to be announced, and a logged out session or a deactivated account kept its open socket too. The gateway now closes a live control socket when its token is deleted, expires, loses shockers.use or its user is deactivated, and when its session is deleted or its account deactivated, including sockets controlling a deactivated owner's hub through a share. Token expiry is enforced on every frame and on the ping. As a fallback for a lost message, each socket re-checks its token or session, the account and its share permissions at most once per revalidation interval, and once right after connecting. Also adds regression tests for share control while the device owner is deactivated.
The API and Cron integration test processes pull the same images in parallel; one can be told the pull succeeded and then fail container creation with 'No such image'.
Token state and shocker permissions are refreshed by several writers (the token subscriber, hub updates and periodic revalidation) that each read the database and then install the result. A read that started earlier but finished later could overwrite a newer pause or share removal until the next revalidation. Each read now takes a generation before it starts, and a result is installed only if no later read has already installed its own. Permissions are kept as a FrozenDictionary that is swapped whole, so frames read it without a lock. Revalidation also checks that the owner of a shared hub is not deactivated, so a lost owner revocation message still closes recipients' sockets. CI: wait on each image pull separately so a failed pull fails the step.
Restores ci-build.yml to its state at the branch point; the change does not belong in the live control revocation fix.
A long-lived connection is authenticated once and then holds its own copy of what it may do. Each kind of connection kept that copy current in its own way, with its own Redis handlers, its own periodic check and its own copy of the rules. This adds one component for all of them. A registry tracks the connections open on an instance by what they depend on, and a single resolver decides whether a connection may go on and what it may do. A connection looks again when it registers, when a change that can affect it is announced, and when time has passed. Only one look runs per connection at a time and a request during one makes it run once more, so an older read cannot replace a newer one. Nothing uses it yet. One-off control and the resolver share one query for who may control which shocker.
Live control reads what it may do from its registry handle on every frame. The token subscriber, the revocation subscriber, the per-connection revalidation and the generation counters that ordered their writes are removed, as the registry does all of it. A hub update now signals the registry instead of refreshing each live control connection in turn, so control commands queued behind it on the hub's channel no longer wait for those database reads. Also gives a live control connection one connection id instead of a new one on every read.
…hority The hub filter registers connections with the registry and makes sure a connection was checked recently before a call. The hub connection tracker and the API's own revocation handlers are removed. A hub connection is still closed when its API token's pause state, permissions or limits change. Renaming a token no longer closes it, and an idle connection whose token expired is now closed instead of staying open until its next call. The API's Redis subscriber only unsubscribes its own channels on shutdown, as it now shares the Redis connection.
A hub was only checked when it connected. A deleted hub, one whose token was regenerated or one whose owner was deactivated kept its open socket. The hub socket is now under the shared connection authority and is closed in those cases. Regenerating a hub token announces a hub update so the gateway holding the old connection sees it.
A deleted session, a deactivated account, a changed API token and a public share whose access changed were each announced on a channel of their own, with a handler of their own on every receiver. They are now one message on one channel that names what changed. A new reason for a connection to look again is one publish call and needs no new subscriber. A message that cannot be read makes every connection look again, as what changed is unknown. Hub changes stay on the hub's own channel, which the gateway holding the hub already listens on. During a rolling deploy, instances on the old version publish on the old channels and are not heard by new ones. A connection that misses a change that way finds out at its next periodic check.
Redis pub/sub delivers a message only to who is listening at that moment. An instance whose Redis connection was down heard no changes, and its connections only found out at their next periodic check. When the subscription connection is restored, live control connections and hub sockets are now checked at once, and hub connections on their next call.
Renames what still carried the names of what it replaced: the hub filter, the account revocation notifier and the test setting for the check interval. A connection's session id is derived from its session token instead of being passed alongside it. Connections accept any grant unless they say otherwise, and both gateway controllers close a revoked socket through one helper. The user hub reads a token's pause state and limits from the connection's grant instead of the token it connected with. The public share hub and the resolver share one definition of a share a visitor can still reach. Removes a live control result that nothing returned, and its metric label.
Contributor
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait...
|
A change to a hub was announced only on the hub's own channel, as a message telling its gateway to load the hub's shockers again. The gateway took every such message to also mean that who may use the hub had changed. Authority had a second path, and a hub socket that was still being set up was not listening on it yet. Hub changes are now announced on the authority channel like every other kind, and a hub's own channel only carries what the hub is told to do. Regenerating a hub token announces an authority change and no reload. Deactivating or reactivating an account no longer tells the gateways to reload that account's hubs. The account's own authority change already reaches every connection that depends on them. Announcing an authority change no longer throws. It happens after the change is saved, the caller can do nothing about a failure, and the affected connections find out at their next periodic check. One call site handled this itself and the others did not.
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.

Why
A long-lived connection is authenticated once and then holds its own copy of what it may do. SignalR hub connections, live control sockets and hub sockets each kept that copy current in their own way: their own Redis handlers, their own periodic check, their own ordering logic and their own copy of the rules. The copies had drifted, and each fix (#407, #416, #417, #421) added another one.
This replaces them with one component.
What
Common/ConnectionAuthority: a registry of the connections open on an instance, indexed by what they depend on, and a singleGrantResolverthat decides whether a connection may go on and what it may do. A connection looks again when it registers, when a change that can affect it is announced, and when time has passed. One look runs per connection at a time and a request during one makes it run once more, so an older read cannot replace a newer one.HubConnectionTrackerand the API's revocation handlers are removed. The user hub reads a token's pause state and limits from the connection's grant.authority-changed, replacessession-revoked,user-auth-revoked,api-token-update:*andpublic-share-access-revoked.Behaviour changes
live_not_enabledframe outcome is removed from the gateway metrics. Nothing ever recorded it.No routes change.
Rollout
During a rolling deploy, instances on the old version publish on the old channels and are not heard by new ones. A connection that misses a change that way finds out at its next periodic check (one minute by default).
Testing
Relation to #421
This branch is built on #421 and contains its commits. Merging this makes #421 redundant.
Summary by CodeRabbit