pub struct MoqConnectAuthz { /* private fields */ }Expand description
CONNECT-time authentication + tenant-binding config for the /moq plane.
When installed on a
crate::transport::quinn_transport::QuinnRpcServer, every /moq
WebTransport CONNECT must present a bearer JWT verifiable with
verify_key; the verified subject is then mapped to a tenant by
tenant_resolver. MoqConnectAuthz::verify returns None on any
failure — missing header, wrong scheme, bad signature, expired/token-not-
yet-valid, wrong audience, or an authenticated subject with no tenant —
and the accept loop refuses the CONNECT (fail-closed). There is no
fall-through to an unscoped consumer: that is the #1145 pattern and the
single most likely way to get this wrong.
Implementations§
Source§impl MoqConnectAuthz
impl MoqConnectAuthz
Sourcepub fn new(
verify_key: VerifyingKey,
tenant_resolver: VerifiedSubjectTenantResolver,
) -> Self
pub fn new( verify_key: VerifyingKey, tenant_resolver: VerifiedSubjectTenantResolver, ) -> Self
Build with the verifying key for the JWT issuer this /moq endpoint
trusts and the authoritative subject→tenant resolver. The endpoint
accepts any aud unless Self::with_expected_aud is set.
Sourcepub fn with_expected_aud(self, aud: impl Into<String>) -> Self
pub fn with_expected_aud(self, aud: impl Into<String>) -> Self
Require the JWT aud to equal aud (trailing-slash tolerant, matches
jwt::decode_with_key). A token with a different aud is rejected,
and — unlike the codebase-wide lenient jwt::decode_with_key — a
token with no aud is also rejected when this is set. On a
dedicated /moq boundary that closes the token-substitution vector
(a token minted for another service, which carries no aud, must not
be admitted here) per BCP 225 / RFC 8725bis. If the operator does not
set this, audience checking is off entirely (their choice).
Sourcepub fn verify(&self, headers: &HeaderMap) -> Option<VerifiedConnect>
pub fn verify(&self, headers: &HeaderMap) -> Option<VerifiedConnect>
Verify the bearer credential in headers and resolve the tenant from
the verified subject.
Returns None — meaning the CONNECT MUST be refused — if:
- no
Authorization: Bearer <jwt>header is present, - the JWT signature,
alg,exp, oriatcheck fails, - the
audcheck fails — including a missingaudwhenSelf::with_expected_audis set (token substitution is not admitted on a boundary that specified an audience), - or
tenant_resolverreturnsNonefor the verified subject.
Every branch is fail-closed; none falls back to an unscoped identity.
Trait Implementations§
Source§impl Clone for MoqConnectAuthz
impl Clone for MoqConnectAuthz
Source§fn clone(&self) -> MoqConnectAuthz
fn clone(&self) -> MoqConnectAuthz
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for MoqConnectAuthz
impl !RefUnwindSafe for MoqConnectAuthz
impl Send for MoqConnectAuthz
impl Sync for MoqConnectAuthz
impl Unpin for MoqConnectAuthz
impl UnsafeUnpin for MoqConnectAuthz
impl !UnwindSafe for MoqConnectAuthz
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more