axess-macros
Procedural macros for the Axess authentication library. Generates Axum middleware layers that enforce authentication state on routes.
Macros
require_authn!
Gates routes by authentication state; caller must be fully Authenticated. Redirects unauthenticated users to a login page, or returns 401 for API endpoints.
(Replaces the previous login_required! macro; same shape, name updated for consistency with the axess Authn* / Authz* convention.)
use require_authn;
// Redirect to /login with ?next= query param:
let app = new
.route
.route_layer;
// Return 401 Unauthorized (API mode, no redirect):
let api = new
.route
.layer;
require_partial_authn!
Restricts routes to sessions in the Authenticating state (mid-MFA). Useful for TOTP verification pages that should only be accessible after the first factor passes.
use require_partial_authn;
let app = new
.route
.route_layer;
require_valid_session
For registry-enforced session checks (forced logout), use the middleware function directly:
use require_valid_session;
let validator = authn.session_validator;
let app = new
.route
.layer;
Installation
These macros are re-exported from the axess facade crate. No separate dependency needed:
use ;
Or depend on axess-macros directly if you only need the macros:
[]
= "0.2"
License
MIT OR Apache-2.0
Security
See SECURITY.md for vulnerability reporting.