Crate axum_jwt_auth

Source
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.
JwtDecoderState
LocalDecoder
Local decoder It uses the given JWKS to decode the JWT tokens.
RemoteJwksDecoder
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.
RemoteJwksDecoderBuilder
Builder for RemoteJwksDecoder.
RemoteJwksDecoderConfig
RemoteJwksDecoderConfigBuilder
Builder for RemoteJwksDecoderConfig.

Enums§

AuthError
An enum representing the possible errors that can occur when authenticating a request. These are sourced from the jsonwebtoken crate and defined here to implement IntoResponse for use in the axum 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.