fix(dashboard): enforce auth lifetimes on live hub connections and circuits (DSH-006)
Hub tokens and cookies bounded only the handshake: an open hub socket kept its connect-time roles and tag grants indefinitely, and a Blazor circuit never revisited its sign-in. The hub-token ticket now carries the token expiry and the hubs are mapped with CloseOnAuthenticationExpiration. Circuits use DashboardRevalidatingAuthenticationStateProvider, which signs a circuit out past the cookie's 8-hour idle lifetime or when a role it holds is no longer granted by GroupToRole. LDAP membership changes and sign-out in another tab are still only picked up at the age limit or on reconnect (documented).
This commit is contained in:
@@ -976,15 +976,36 @@ dashboard mints short-lived bearer tokens for the connection:
|
||||
it must never be request-logged (see the remarks on
|
||||
`HubTokenAuthenticationHandler`).
|
||||
4. `HubTokenAuthenticationHandler` validates the protected payload and
|
||||
rebuilds the `ClaimsPrincipal` with the carried roles.
|
||||
rebuilds the `ClaimsPrincipal` with the carried roles, and stamps the
|
||||
token's expiry on the authentication ticket (`ExpiresUtc`).
|
||||
5. The hubs' `[Authorize(Policy = HubClientsPolicy)]` accepts the resulting
|
||||
identity.
|
||||
6. Every hub is mapped with `CloseOnAuthenticationExpiration`, so SignalR closes
|
||||
the connection when that ticket expires (DSH-006). Before this, the 5-minute
|
||||
lifetime bounded only the handshake: an open socket kept the roles and tag
|
||||
grants it connected with for as long as it stayed up, and each later
|
||||
`SubscribeSession` on it was decided from those frozen claims. A
|
||||
cookie-authenticated hub connection closes at the cookie ticket's expiry the
|
||||
same way. The client reconnects with a freshly minted token.
|
||||
|
||||
There is no in-repo hub client: the helper that once wrapped `HubConnectionBuilder`
|
||||
for a circuit was deleted when the pages moved to the in-process seams. An external
|
||||
client re-fetches `/hubs/token` on every (re)connect itself, which is what makes the
|
||||
short 5-minute lifetime transparent.
|
||||
|
||||
Blazor circuits have the same capture-once problem — a circuit takes its principal
|
||||
from the HTTP request that started it and an open tab sends no further requests — so
|
||||
the dashboard replaces the default `ServerAuthenticationStateProvider` with
|
||||
`DashboardRevalidatingAuthenticationStateProvider` (DSH-006). Every minute it signs
|
||||
the circuit out (anonymous state) when the circuit is older than the cookie's 8-hour
|
||||
idle lifetime, or when the principal holds a role that its LDAP group claims no
|
||||
longer map to under the current `Dashboard:GroupToRole`. Pages under
|
||||
`AuthorizeRouteView` then re-render as not authorized, and admin actions, which read
|
||||
the provider at action time, are refused. A change to the user's LDAP group
|
||||
membership and a sign-out in another tab are not observable there (no server-side
|
||||
session, no password to re-bind with); they take effect at the age limit or on
|
||||
reconnect. The `DisableLogin` dev bypass is never signed out.
|
||||
|
||||
Caveat — logout does not revoke outstanding tokens. Logout clears the dashboard
|
||||
cookie, but hub bearer tokens are self-contained, data-protection-encrypted, and
|
||||
carry no server-side revocation state (no jti denylist). A token captured before
|
||||
|
||||
Reference in New Issue
Block a user