Skip to content

OIDC (JWKS bearer)

Requires the oidc extra. See the Auth guide.

rn_forge.django.auth.drf.oidc

JWKS bearer authentication for externally issued tokens in DRF.

JWKSBearerAuthentication

Bases: PrincipalBearerAuthentication

Authenticate a bearer token against a remote OIDC JWKS endpoint.

Set jwks_url, issuer and audience on a subclass. Authenticators and key sets are cached per subclass and process.

Verification and the claims-to-principal mapping are :class:rn_forge.auth.oidc.OidcAuthenticator's, so this stack accepts the same tokens as a FastAPI service wired to the same IdP. Accounts are linked as in :class:PrincipalBearerAuthentication, so set accounts and contexts too.

cache_timeout = 300.0 class-attribute

Seconds a fetched key set stays cached.

cooldown_duration = 30.0 class-attribute

The fewest seconds between two key set fetches.

claims_to_principal(claims)

Map verified claims to the principal on request.user.