xjp-oidc - OpenID Connect SDK for Rust
A comprehensive OpenID Connect (OIDC) and OAuth 2.0 SDK for Rust, supporting both server-side and WebAssembly environments.
δΈζζζ‘£ | English
Features
-
π Complete OAuth2/OIDC Implementation
- Authorization Code Flow with PKCE
- OIDC Discovery
- JWKS Caching
- ID Token Verification
- Custom Claims Support
-
π Multi-Platform Support
- Native Rust (Linux, macOS, Windows)
- WebAssembly (Browser)
- Conditional Compilation
-
π Production Ready
- Enterprise Features (DCR, RP-Initiated Logout)
- JWT Access Token Verification
- Multi-Issuer Support
- Comprehensive Error Handling
-
π§ Framework Integration
- Axum Middleware and Extractors
- Tower Service Compatible
- Type-Safe Claim Extraction
Quick Start
Add to your Cargo.toml:
[]
= "1.0.0-rc.1"
# For Axum integration
= "1.0.0-rc.1"
Basic usage:
use ;
use ;
// 1. Create PKCE challenge
let = create_pkce?;
// 2. Build authorization URL
let auth_url = build_auth_url?;
// 3. After callback, exchange code for tokens
let tokens = exchange_code.await?;
// 4. Verify ID token
let verified = verify_id_token.await?;
Examples
The repository includes several comprehensive examples:
Auth BFF Service
A production-ready authentication backend service:
Resource Server
JWT-protected API example:
DCR Tool
Dynamic Client Registration CLI:
Documentation
- Getting Started Guide - Quick introduction and setup
- API Reference - Complete API documentation
- Security Best Practices - Security guidelines
- Troubleshooting - Common issues and solutions
Platform Support
| Platform | Features | Status |
|---|---|---|
| Linux x86_64 | Full | β Supported |
| macOS (Intel/ARM) | Full | β Supported |
| Windows | Full | β Supported |
| WebAssembly | Core | β Supported |
Security
Security is our top priority. Please see SECURITY.md for:
- Vulnerability reporting process
- Security best practices
- Update policy
Contributing
We welcome contributions! Please see CONTRIBUTING.md for:
- Code of conduct
- Development setup
- Submission guidelines
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT license (LICENSE-MIT)
at your option.
Project Structure
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
Minimum Supported Rust Version
MSRV: 1.82
Support
- GitHub Issues: Report bugs
- Discussions: Ask questions
- Security: security@xiaojinpro.com
Built with β€οΈ by the XiaojinPro team