JWT authentication middleware for Axum applications
AuthLayer
provides JWT token validation middleware that integrates seamlessly with Axum web applications. It validates Bearer tokens, extracts user context, and makes it available to your route handlers.
AuthLayer::new()
constructor uses the public key from the global SDK configuration:
Authorization: Bearer <token>
headerAuthContext
from token claimsAlgorithm | Type | Description |
---|---|---|
HS256/384/512 | HMAC | Symmetric key signing |
RS256/384/512 | RSA | Asymmetric RSA signing |
ES256/384 | ECDSA | Elliptic curve signing |
AuthContext
is added to request extensions:
Extension
extractor:
X-Auth-Error
header with error detailsWWW-Authenticate: Bearer
header