Expand description
A Rust library for JWT authentication with support for both local keys and remote JWKS (JSON Web Key Sets).
This crate provides a flexible JWT authentication system that can:
- Validate tokens using local RSA/HMAC keys
- Automatically fetch and cache remote JWKS endpoints
- Integrate seamlessly with the Axum web framework
- Handle token validation with configurable options
It builds on top of the jsonwebtoken
crate to provide higher-level authentication primitives
while maintaining full compatibility with standard JWT implementations.
§Example
For a full example, see the examples.
Structs§
- Claims
- A generic struct for holding the claims of a JWT token.
- JwtDecoder
State - Local
Decoder - Local decoder It uses the given JWKS to decode the JWT tokens.
- Remote
Jwks Decoder - Remote JWKS decoder. It fetches the JWKS from the given URL and caches it for the given duration. It uses the cached JWKS to decode the JWT tokens.
- Remote
Jwks Decoder Builder - Builder for
RemoteJwksDecoder
. - Remote
Jwks Decoder Config - Remote
Jwks Decoder Config Builder - Builder for
RemoteJwksDecoderConfig
.
Enums§
- Auth
Error - An enum representing the possible errors that can occur when authenticating a request.
These are sourced from the
jsonwebtoken
crate and defined here to implementIntoResponse
for use in theaxum
framework. - Error
Traits§
- JwtDecoder
- A generic trait for decoding JWT tokens.
Type Aliases§
- Decoder
- A type alias for a decoder that can be used as a state in an Axum application.