Skip to main content

Module moq_connect_auth

Module moq_connect_auth 

Source
Expand description

CONNECT-time authentication + tenant binding for the /moq WebTransport plane (#1153). CONNECT-time authentication for the /moq WebTransport plane (#1153).

The /moq WebTransport CONNECT is an entry point onto a shared streaming plane. This module authenticates it before any stream is established (the accept loop verifies the credential and refuses the CONNECT — by dropping the request, never completing the handshake — before Request::ok() runs), then binds the accepted session to a tenant derived from the verified identity.

§Credential accepted, and why

The accepted credential is a bearer JWT carried in the HTTP/3 [Authorization] header (Authorization: Bearer <jwt>). It is verified, not merely parsed: crate::auth::jwt::decode_with_key checks the EdDSA signature (and rejects any non-EdDSA alg, defeating algorithm-confusion), exp/iat validity, and the expected aud. A forged signature, a stripped claim, or an expired token fails closed.

This reuses the same verified-identity primitive the RPC envelope path uses (hyprstream_rpc::auth::jwt/Claims) so the /moq plane and the RPC plane agree on what “verified subject” means — the derivation can be shared with the sibling Casbin-domain work (#1151) rather than invented a second time.

§Why the tenant is NOT read from the token

Per the #1128 spike and #1146 (T2.1 / PR #1147), JWT scope/claim fields are not enforced at the verifier today — any tenant-shaped claim inside the token is caller-supplied data and therefore unenforceable (the existing cap field is the cautionary tale: present, unread). So the tenant is never taken from the token. It is derived, server-side, from the verified subject by [MoqConnectAuthz::tenant_resolver] — an authoritative subject→tenant provisioning map the operator controls. The token proves who the peer is; the resolver is the trust root for which tenant that subject belongs to. See VerifiedConnect.

§What this guarantees today (read before assuming isolation)

With a MoqConnectAuthz installed, an unauthenticated or tenant-less /moq CONNECT is refused (fail-closed), and a connected peer can only enumerate/subscribe to its own tenant’s broadcasts (structural scoping via crate::moq_authz::tenant_scoped_consumer). This is a transport-plane, metadata/announce isolation boundary on the /moq consumer path. It is NOT a cluster-wide tenant guarantee: frame content was already AEAD-sealed + chained-HMAC’d at the source (the relay/consumer holds no enc_key/mac_key), and other planes (RPC subject authorization, event prefixes, VFS) have their own independent stories documented in the #1128 spike. Relay-mode (with_moq_relay) additionally refuses unauthenticated CONNECTs but the relay still routes by track name — it must, to rendezvous publisher and subscriber — so announce-name visibility through a relay is inherent to relay mode and not something this boundary removes.

Structs§

MoqConnectAuthz
CONNECT-time authentication + tenant-binding config for the /moq plane.
VerifiedConnect
The outcome of a successful CONNECT-time verification: a peer whose subject was verified by signature, and the tenant the server resolved for that subject. The tenant is authoritative server-side state, not a caller-supplied field.

Constants§

AUTHORIZATION_HEADER
HTTP/3 header carrying the bearer JWT.
BEARER_SCHEME
Scheme expected in the Authorization header value.

Functions§

bearer_token
Extract the bearer token from the Authorization header.

Type Aliases§

VerifiedSubjectTenantResolver
Server-side map from a verified subject to its tenant.