Skip to main content

Module policy

Module policy 

Source
Expand description

Purpose-bound claim validation — a faithful port of auth_service’s crypto/jwt.rs ValidationPolicy/TokenPurpose/validate_claims so consumers apply exactly the contract the issuer enforces.

Semantics mirrored from backends/rust/auth_service/src/crypto/jwt.rs:

  • trusted_issuers: exact-match allow-list; empty = no issuer pinning. A pinned policy requires a nonblank string iss in that allow-list. Issuer-less compatibility requires an explicitly unpinned raw policy.
  • expected_audiences: empty = unpinned; non-empty requires the token’s aud (string or array) to intersect the expected set.
  • purpose binds the type claim + required claims (sub/exp/iat, iss/aud/auth_time for ID tokens, sub == client_id for internal assertions).

WP-05a adds the RFC 9068 §2.1 JOSE typ check layered on top: ValidationPolicy::require_at_jwt (default on for access purposes) demands a typ header of at+jwt (or the media-type form application/at+jwt), which auth_service mints on every access token since WP-03b. allow_legacy_typ() opens the compat window for tokens minted before the profile landed.

Structs§

ValidationPolicy
Claim-level validation applied after signature verification.

Enums§

TokenPurpose
The purpose a validated credential must serve (mirrors TokenPurpose).

Functions§

is_at_jwt_typ
Returns true when the JOSE typ header names the RFC 9068 profile. typ compares case-insensitively as a media type; application/at+jwt is the explicit-registration equivalent of at+jwt.
validate_claims
Bind a verified claim set to its purpose: exact type, required claims, issuer allow-list, audience allow-list. Byte-for-byte port of the service’s validate_claims.
validate_typ_header
Check the JOSE typ header for the policy’s purpose. Call before signature verification — a wrong typ means the token is not even the right credential class.