Expand description
§xjp-oidc
A comprehensive OIDC/OAuth2 SDK for Rust with support for both server and WASM environments.
§Features
- Authorization Code Flow with PKCE
- OIDC Discovery and JWKS caching
- ID Token verification with standard claims validation
- Dynamic Client Registration (server-only)
- RP-Initiated Logout
- Resource Server JWT verification
- Optional Axum integration
§Example
use xjp_oidc::{create_pkce, build_auth_url, BuildAuthUrl};
// Create PKCE challenge
let (verifier, challenge, method) = create_pkce()?;
// Build authorization URL
let auth_result = build_auth_url(BuildAuthUrl {
issuer: "https://auth.example.com".into(),
client_id: "my-client".into(),
redirect_uri: "https://app.example.com/callback".into(),
scope: "openid profile email".into(),
code_challenge: challenge,
state: None,
nonce: None,
prompt: None,
extra_params: None,
tenant: None,
authorization_endpoint: None,
})?;
let auth_url = auth_result.url;
// Save auth_result.state and auth_result.nonce for later validationRe-exports§
pub use cache::Cache;pub use cache::NoOpCache;pub use cache::MemoryCache;pub use cache::LruCacheImpl;lrupub use cache::MokaCacheImpl;Non-WebAssembly and mokapub use errors::Error;pub use http::HttpClient;pub use http::HttpClientError;pub use http::ReqwestHttpClient;Non-WebAssembly and http-reqwestpub use types::*;
Modules§
- cache
- Cache abstraction for JWKS and discovery metadata
- discovery_
tenant - OIDC Discovery implementation with multi-tenant support
- errors
- Error types for xjp-oidc SDK
- http
- HTTP client abstraction for both server and WASM environments
- http_
tenant - HTTP client extension for multi-tenant support
- prelude
- Prelude module for convenient imports
- sse
Non-WebAssembly - Server-Sent Events (SSE) support for login flows
- tenant
- Multi-tenant support for OIDC SDK
- types
- Public types for the xjp-oidc SDK
Structs§
- Jwk
- JSON Web Key (JWK) structure
- Jwks
- JSON Web Key Set (JWKS)
- JwtVerifier
verifier - JWT Verifier for Resource Server
- Oidc
Client Non-WebAssembly and http-reqwestandmoka - Default OIDC client with built-in HTTP and cache implementations
Constants§
- VERSION
- SDK version
Functions§
- build_
auth_ url - Build an authorization URL for the OAuth2/OIDC flow
- build_
auth_ url_ with_ metadata - Build authorization URL from provider metadata
- build_
end_ session_ url - Build an end session (logout) URL
- build_
end_ session_ url_ with_ discovery - Build an end session URL with discovery metadata
- create_
pkce - Generate a PKCE verifier/challenge pair
- discover
- Discover OIDC provider metadata from issuer URL
- exchange_
code Non-WebAssembly - Exchange authorization code for tokens
- fetch_
jwks - Fetch JWKS from the endpoint
- get_
client_ config Non-WebAssembly - Get client configuration from the authorization server
- get_
userinfo - Get user information from the UserInfo endpoint
- introspect_
token Non-WebAssembly - Introspect a token to determine its active state and metadata
- parse_
callback_ params - Parse callback parameters from the authorization response
- refresh_
token Non-WebAssembly - Refresh an access token using a refresh token
- register_
client Non-WebAssembly - Register a new client with the authorization server
- revoke_
token Non-WebAssembly - Revoke a token (access token or refresh token)
- verify_
id_ token - Verify an ID token and return verified claims