Crate axum_jwt_ware

Source
Expand description

§Axum JWT Ware

Simple Axum + JWT authentication middleware with implemented Login and refresh token.

§Goal

I aim to simplify the process for developers/indie hackers to focus on writing their core business logic when starting a new project, rather than spending time rewriting authentication.

Structs§

AuthLayer
The auth layer that can be used to protect routes.
AuthService
The auth service that will be used by the AuthLayer.
Authenticator
Claims
The claims that will be encoded into the JWT.
CurrentUser
The user object that will be returned from the UserData trait.
DecodingKey
All the different kind of keys we can use to decode a JWT. This key can be re-used so make sure you only initialize it once if you can for better performance.
EncodingKey
A key to encode a JWT with. Can be a secret, a PEM-encoded key or a DER-encoded key. This key can be re-used so make sure you only initialize it once if you can for better performance.
Error
An error that can occur when encoding/decoding JWTs
Header
A basic JWT header, the alg defaults to HS256 and typ is automatically set to JWT. All the other fields are optional.
LoginResponse
The response body for the login handler.
RefreshBody
The request body for the refresh token handler.
RequestBody
The request body for the login handler.
Validation
Contains the various validations that are applied after decoding a JWT.

Enums§

Algorithm
The algorithms supported for signing/verifying JWTs
AuthError
The error type for the auth module.

Traits§

Deserialize
A data structure that can be deserialized from any data format supported by Serde.
Serialize
A data structure that can be serialized into any data format supported by Serde.
UserData

Functions§

auth_token_decode
Decode a token.
auth_token_encode
Encode a new token.
decode
Decode and validate a JWT
encode
Encode the header and claims given and sign the payload using the algorithm from the header and the key. If the algorithm given is RSA or EC, the key needs to be in the PEM format.
login
The login handler.
refresh_token
The refresh token handler.

Derive Macros§

Deserialize
Serialize