Expand description
A minimal OpenID Connect client library, part of the
axum-security workspace and
layered on axum-security-oauth2
for the OAuth2 half of the flow.
Compared to the openidconnect
crate this one has no typestate and no type parameters: ID tokens are
verified with a single concrete IdTokenVerifier, and the standard claim
set is a plain OidcClaims struct with &str fields plus an extra map
for everything nonstandard.
This first slice is the verification core: given a JWK set and an ID
token, IdTokenVerifier::verify checks the signature (with algorithm
allow-listing), the iss/aud/exp/nbf claims, and the nonce, using
jsonwebtoken on top of aws-lc-rs. Discovery, JWKS fetching/caching, the
login flow, and RP-initiated logout are layered on in later phases.
§Example
use axum_security_oidc::{IdTokenVerifier, JwkSet};
let jwks: JwkSet = serde_json::from_str(jwks_json)?;
let verifier = IdTokenVerifier::new("https://issuer.example", "my-client-id", jwks);
let verified = verifier.verify(id_token, expected_nonce)?;
let claims = verified.claims()?;
let _subject = claims.subject;§Features
jiff/chrono/time— add typed timestamp accessors toOidcClaims/UtcTimestamp. Off by default; the core exposes raw unix seconds (i64).
Modules§
- providers
- Issuer URLs for common OpenID Connect providers, used by the
OidcClientdiscovery shortcuts.
Structs§
- Csrf
Token - Re-exported from
axum_security_oauth2: the shared HTTP backend used for discovery and JWKS fetches (clone the login flow’s client in so both ride one connection pool), theCsrfTokencarried byOidcLogin, and theConfigErrorwrapped byOidcBuilderError::OAuth2. The CSRF token embedded in the authorization URL’sstateparameter. - Http
Response - Re-exported from
axum_security_oauth2: the shared HTTP backend used for discovery and JWKS fetches (clone the login flow’s client in so both ride one connection pool), theCsrfTokencarried byOidcLogin, and theConfigErrorwrapped byOidcBuilderError::OAuth2. The response fromHttpClient::get: the HTTP status and the raw body. - IdToken
Verifier - Verifies OpenID Connect ID tokens against a JWK set.
- JwkSet
- Re-exported from
jsonwebtoken: the signing-algorithm enum forIdTokenVerifier::algorithms, and the JWK-set typeIdTokenVerifier::newtakes. A JWK set - Jwks
Cache - A JWKS-backed ID-token verifier that fetches (and caches) the provider’s signing keys.
- Logout
Url - Builds an RP-Initiated Logout URL (OpenID Connect RP-Initiated Logout 1.0):
the provider’s
end_session_endpointwith the optional parameters appended as query string. - Oidc
Address - The
addressclaim from an OpenID Connect ID token. - Oidc
Claims - Claims from a verified OpenID Connect ID token.
- Oidc
Client - An OpenID Connect client: the OAuth2 authorization-code login flow plus ID-token verification.
- Oidc
Client Builder - Builds an
OidcClient. Created withOidcClient::builder,OidcClient::discover, or a provider shortcut. - Oidc
Login - The first leg of an OpenID Connect login, created by
OidcClient::start_login. - Oidc
Tokens - The result of a successful login: the verified ID token plus the OAuth2
tokens. Created by
OidcClient::finish_login. - Provider
Metadata - OpenID Connect provider metadata, from a
.well-known/openid-configurationdocument (OpenID Connect Discovery 1.0 §3). - UtcTimestamp
- A UTC timestamp represented as seconds since the Unix epoch.
- Verified
IdToken - A successfully verified ID token.
Enums§
- Algorithm
- Re-exported from
jsonwebtoken: the signing-algorithm enum forIdTokenVerifier::algorithms, and the JWK-set typeIdTokenVerifier::newtakes. The algorithms supported for signing/verifying JWTs - Claims
Error - A failure while deserializing a verified ID token’s payload into
OidcClaims. - Config
Error - Re-exported from
axum_security_oauth2: the shared HTTP backend used for discovery and JWKS fetches (clone the login flow’s client in so both ride one connection pool), theCsrfTokencarried byOidcLogin, and theConfigErrorwrapped byOidcBuilderError::OAuth2. Errors fromOAuth2ClientBuilder::try_build. - Discovery
Error - A failure while fetching OpenID Connect provider metadata from a
.well-known/openid-configurationdocument. - Http
Client - Re-exported from
axum_security_oauth2: the shared HTTP backend used for discovery and JWKS fetches (clone the login flow’s client in so both ride one connection pool), theCsrfTokencarried byOidcLogin, and theConfigErrorwrapped byOidcBuilderError::OAuth2. The HTTP backend used for token requests. - Oidc
Builder Error - Errors from
OidcClientBuilder::try_build. - Oidc
Error - A failure in the OpenID Connect login flow
(
OidcClient::finish_login). - Verify
Error - A failure while verifying an ID token.
Constants§
- DEFAULT_
MIN_ REFETCH_ INTERVAL - Default minimum time between JWKS refetch attempts triggered by an unknown
signing key; bounds the JWKS load a stream of bogus-
kidtokens can cause.