fix(auth): revoking, rotating or deleting a key ends its open gRPC streams (SEC-004)
A streaming call was authenticated only at open, and revoke/rotate/delete only evicted the verification cache, so a leaked key's open StreamEvents/StreamAlarms kept delivering after the revoke. The interceptor now registers every streaming call by key id in ApiKeyStreamRegistry and gives the handler a call context whose token also fires on revoke; the dashboard key actions call Revoke, and the call ends with Unauthenticated.
This commit is contained in:
@@ -105,6 +105,26 @@ Two rules keep the holder of the correct secret from being denied by a spray aga
|
||||
|
||||
The dashboard login surface is throttled independently: `POST /auth/login` carries a fixed-window ASP.NET Core rate-limiter policy keyed per remote IP (`MxGateway:Security:LoginRateLimit*`), rejecting a burst with HTTP 429 before the LDAP bind is relayed to the directory. See [GatewayConfiguration](./GatewayConfiguration.md#security-options).
|
||||
|
||||
### Streaming calls and revocation
|
||||
|
||||
A streaming call is authenticated once, when it opens. To keep a revoked key from
|
||||
holding a stream open indefinitely (SEC-004), the interceptor registers every
|
||||
streaming call (server, client and duplex) in `ApiKeyStreamRegistry` under the
|
||||
caller's key id, and hands the handler a `RevocableServerCallContext`: the real call
|
||||
context with a cancellation token that also fires when the key is revoked. The
|
||||
dashboard API Keys page calls `ApiKeyStreamRegistry.Revoke(keyId)` on Revoke, Rotate
|
||||
and Delete, right after it evicts the verification cache. The handler stops on its
|
||||
token as it would for a client cancel, and the interceptor reports the end of the
|
||||
call as `Unauthenticated` — the status a new call with that key now gets — whatever
|
||||
status the handler mapped its cancellation to. Rotate ends the key's streams too,
|
||||
since they were opened with the secret the rotation retires; the client reconnects
|
||||
with the new secret. Unary calls are not tracked: they complete within the command
|
||||
timeout.
|
||||
|
||||
Only revocations made inside the gateway process reach the registry. A key revoked
|
||||
by the separate `apikey` CLI process keeps its open streams until they reconnect,
|
||||
the same out-of-band window its verification-cache entry has.
|
||||
|
||||
## Scope Resolution
|
||||
|
||||
`GatewayGrpcScopeResolver` is a stateless singleton that switches on the runtime request type. Top-level RPC requests map directly:
|
||||
|
||||
Reference in New Issue
Block a user