async-oidc-jwt-validator
A fast, secure, and easy-to-use Rust crate for validating OpenID Connect (OIDC) JWTs.
This library provides a simple way to protect your backend services by verifying tokens from providers like Keycloak, Auth0, or Okta. It handles the complexities of fetching, caching, and refreshing JSON Web Keys (JWKS) automatically.
Features
-
Built with
async/await
from the ground up to be non-blocking and highly performant. Perfect for Axum, Actix Web, Tonic, and any modern Rust web service. -
Caches JSON Web Key Sets (JWKS) in memory to eliminate latency from repeated fetch(). The cache is thread-safe (
Arc<RwLock>
). Ready for highly concurrent applications. -
Just provide your provider's issuer URL, and the library discovers the correct JWKS endpoint using the standard OIDC Discovery (
/.well-known/openid-configuration
), saving you from hardcoding URLs. -
Comes with a simple
validate()
method that enforces standard OIDC security checks (issuer, audience, signature, expiration) out-of-the-box. -
Works seamlessly with Keycloak, Auth0, Okta, Google, and any other OpenID Connect compliant identity provider.
Installation
Add this to your Cargo.toml
:
[]
= "0.1.2"
Usage
Quick Start
use ;
use ;
async
Manual JWKS Configuration
If you prefer to manually specify the JWKS URI:
let config = new;
let validator = new;
Custom Validation
For more control over the validation process:
let mut validation = new;
validation.set_issuer;
validation.set_audience;
match validator..await
License
Licensed under MIT license
Contribution
See CONTRIBUTING.md.