axum-jose
Lightweight authorization middleware for axum, following
JOSE (JSON Object Signing and Encryption) standards.
Overview
Add JWT-based authorization to your axum applications with a simple,
tower-compatible middleware layer that integrates seamlessly with OpenID Connect and
OAuth2 providers.
More broadly speaking, this crate follows the JOSE (JSON Object Signing and Encryption) framework which is an umbrella for specifications that form the foundation of modern authentication and authorization protocols. Core specifications include e.g. JSON Web Signatures (JWS), JSON Web Encryption (JWE), JSON Web Algorithms (JWA), JSON Web Keys (JWK), which provide the building blocks for JSON Web Tokens (JWT).
Features
- JWT Validation: Transparently extract JWTs from
Authorizationheaders and validate them against JWK sets to authorize incoming requests. - Caching: Use caching to minimize latency and avoid fetching JWK sets from authorization servers on every request.
- Rate Limiting: Prevent running into your identity provider's rate limits when fetching JWKs by configuring client-side rate limiting.
Quickstart
use ;
use ;
use NonZero;
use Duration;
use Url;
async
See the documentation for more examples and configuration options.
Related Projects
At the time of writing, the ecosystem around JOSE, OpenID Connect, and OAuth2 for axum and Rust is not yet as mature
as in other languages and web frameworks. There is no clear best practice for implementing authorization for
axum-based APIs but a number of crates, similar to this one, exist. To name a few:
License
This project is licensed under the MIT License.