Skip to main content

rs_identity_model/
lib.rs

1//! # identity-model
2//!
3//! Production-grade, RFC-compliant OIDC/OAuth2 **client** library for Rust —
4//! part of the cross-language [identity-model](https://github.com/jamescrowley321/identity-model)
5//! family that shares one conformance specification across languages.
6//!
7//! ## Status
8//!
9//! The Core tier — discovery, JWKS retrieval and key resolution, JWT
10//! validation (including the OIDC ID-token profile), client-credentials and
11//! authorization-code + PKCE token flows, and UserInfo — is implemented, as is
12//! Extended token introspection (RFC 7662), revocation (RFC 7009), the token
13//! exchange grant (RFC 8693), and the key/proof/verify half of DPoP
14//! (RFC 9449 — see [`dpop`] for what is not yet covered). Behavior is proven
15//! against the cross-language conformance vectors in the repository's `spec/`.
16//!
17//! ## Module Overview
18//!
19//! - [`discovery`] — OIDC Discovery client
20//! - [`jwks`] — JWKS fetch + key resolution
21//! - [`jwt`] — JWT signature + claims validation, ID token validation
22//! - [`token`] — client credentials, authorization code, PKCE, token exchange
23//! - [`introspection`] — token introspection (RFC 7662)
24//! - [`revocation`] — token revocation (RFC 7009)
25//! - [`dpop`] — DPoP sender-constrained tokens (RFC 9449)
26//! - [`userinfo`] — UserInfo endpoint client
27//! - [`error`] — the crate error type, [`IdentityError`]
28
29pub mod discovery;
30pub mod dpop;
31pub mod error;
32pub mod introspection;
33pub mod jwks;
34pub mod jwt;
35pub mod revocation;
36pub mod token;
37pub mod userinfo;
38
39/// Shared client-authentication and HTTP-form helpers (client_secret_basic /
40/// _post encoding, capped body reads, OAuth error bodies). Internal.
41mod client_auth;
42
43/// Shared HTTP client construction (redirect-downgrade defence). Internal.
44mod http;
45
46/// Internal helpers for reading numeric configuration from the environment.
47mod env;
48
49pub use discovery::{DiscoveryClient, DiscoveryClientBuilder, DiscoveryError, ProviderMetadata};
50pub use dpop::{
51    DPOP_PROOF_TYP, DpopAlgorithm, DpopKey, DpopProof, DpopProofOptions, DpopVerifyOptions,
52    ath as dpop_ath, jwk_thumbprint, normalize_htu as dpop_normalize_htu, verify_bound_proof,
53    verify_proof,
54};
55pub use error::IdentityError;
56pub use http::secure_client_builder;
57pub use introspection::{
58    Introspection, IntrospectionAudience, IntrospectionClient, IntrospectionClientBuilder,
59};
60pub use jwks::{JsonWebKey, JsonWebKeySet, JwksClient, JwksClientBuilder};
61pub use jwt::{
62    Audience, BoxedClaimsValidator, Claims, ClaimsValidationError, ClaimsValidator, CombineMode,
63    CombinedValidator, DEFAULT_ALLOWED_ALGORITHMS, IdTokenValidationOptions,
64    IdTokenValidationOptionsBuilder, ValidationOptions, ValidationOptionsBuilder, boxed,
65    combine_claims_validators, from_fn, require_claim_value, require_claims, require_scopes,
66    validate_id_token, validate_id_token_claims, validate_token, validate_token_with_jwks,
67};
68pub use revocation::{RevocationClient, RevocationClientBuilder};
69pub use token::{
70    ClientAuthMethod, PkceChallenge, TOKEN_TYPE_ACCESS_TOKEN, TOKEN_TYPE_ID_TOKEN, TOKEN_TYPE_JWT,
71    TOKEN_TYPE_REFRESH_TOKEN, TOKEN_TYPE_SAML1, TOKEN_TYPE_SAML2, TOKEN_TYPE_URIS, TokenClient,
72    TokenClientBuilder, TokenExchangeRequest, TokenResponse, authorization_url,
73};
74pub use userinfo::{Address, UserInfoClient, UserInfoClientBuilder, UserInfoResponse};
75
76/// Convenience alias for results returned across the crate.
77pub type Result<T> = std::result::Result<T, IdentityError>;