Skip to main content

Module client_auth

Module client_auth 

Source
Expand description

OAuth 2.1 client authentication at the token endpoint.

Currently supports:

  • none — public client; PKCE substitutes for client auth
  • private_key_jwt — RFC 7521 / RFC 7523 §2.2 client assertion

The client assertion is a JWT signed by one of the keys in the registered client’s jwks field (inline) or via jwks_uri (deferred). Claim requirements per RFC 7523 §3 + the atproto OAuth profile (#1146 T1.2/T3.3): iss == sub == client_id aud == the AS issuer. The atproto OAuth profile mandates this form; RFC 7523 §3 permits the token endpoint URL too, but this AS accepts the issuer ALONE at every endpoint (PAR and token) — see #1146 T1.2. exp > now iat present and not in the future (beyond 60s clock skew) jti present and unique per client until exp (replay registry in OAuthState::assertion_jti_seen) alg per the JWKS key kty/crv (RS256, ES256, EdDSA)

Spec reference: MCP 2025-11-25 § Client ID Metadata Documents lists private_key_jwt as a MAY for clients (CIMD §6.2). Servers honoring the token_endpoint_auth_method field in a CIMD/DCR registration MUST validate the assertion before issuing tokens.

Structs§

VerifiedAssertion
A successfully verified client assertion.

Enums§

ClientAuthError
Client authentication failure.

Constants§

JWT_BEARER_ASSERTION_TYPE

Functions§

requires_private_key_jwt
Decide whether a registered client requires private_key_jwt. Default is “no” — i.e. public client / PKCE-only — unless the registration explicitly set token_endpoint_auth_method=private_key_jwt.
verify_assertion_with_keys
Pure-sync core verification: given a set of candidate keys, verify the JWT’s signature and claims. Used both by the async public entry point and directly by unit tests.
verify_client_assertion
Verify an RFC 7523 client_assertion against the registered client’s JWKS — inline jwks if present, otherwise fetched from jwks_uri (cached for state.client_jwks_uri_cache_ttl). expected_audiences is the accepted aud set — on every profile path this is the AS issuer alone (atproto mandate, #1146 T1.2).