Crates.io | xjp-oidc-axum |
lib.rs | xjp-oidc-axum |
version | 1.0.0 |
created_at | 2025-09-20 00:38:08.965442+00 |
updated_at | 2025-09-23 08:17:25.215955+00 |
description | Axum integration for xjp-oidc - OIDC/OAuth2 middleware and extractors |
homepage | https://github.com/xiaojinpro/xjp-oidc |
repository | https://github.com/xiaojinpro/xjp-oidc |
max_upload_size | |
id | 1847298 |
size | 19,633 |
A comprehensive OpenID Connect (OIDC) and OAuth 2.0 SDK for Rust, supporting both server-side and WebAssembly environments.
δΈζζζ‘£ | English
π Complete OAuth2/OIDC Implementation
π Multi-Platform Support
π Production Ready
π§ Framework Integration
Add to your Cargo.toml
:
[dependencies]
xjp-oidc = "1.0.0-rc.1"
# For Axum integration
xjp-oidc-axum = "1.0.0-rc.1"
Basic usage:
use xjp_oidc::{create_pkce, build_auth_url, exchange_code, verify_id_token};
use xjp_oidc::types::{BuildAuthUrl, ExchangeCode, VerifyOptions};
// 1. Create PKCE challenge
let (verifier, challenge, _) = create_pkce()?;
// 2. Build authorization URL
let auth_url = build_auth_url(BuildAuthUrl {
issuer: "https://auth.example.com".into(),
client_id: "your-client-id".into(),
redirect_uri: "https://app.example.com/callback".into(),
scope: "openid profile email".into(),
code_challenge: challenge,
..Default::default()
})?;
// 3. After callback, exchange code for tokens
let tokens = exchange_code(params, &http_client).await?;
// 4. Verify ID token
let verified = verify_id_token(&tokens.id_token, options).await?;
The repository includes several comprehensive examples:
A production-ready authentication backend service:
cd auth-bff
cargo run
JWT-protected API example:
cd examples/resource-server
cargo run
Dynamic Client Registration CLI:
cd examples/dcr-registration
cargo run -- register
Platform | Features | Status |
---|---|---|
Linux x86_64 | Full | β Supported |
macOS (Intel/ARM) | Full | β Supported |
Windows | Full | β Supported |
WebAssembly | Core | β Supported |
Security is our top priority. Please see SECURITY.md for:
We welcome contributions! Please see CONTRIBUTING.md for:
Licensed under either of:
at your option.
xjp-oidc/
βββ xjp-oidc/ # Core SDK
βββ xjp-oidc-axum/ # Axum integration
βββ auth-bff/ # Auth BFF service example
βββ examples/
β βββ resource-server/ # Resource server example
β βββ dcr-registration/ # DCR CLI tool
βββ docs/ # Documentation
MSRV: 1.82
Built with β€οΈ by the XiaojinPro team