Skip to main content

Module guards

Module guards 

Source
Expand description

Request guards — composable preconditions evaluated before a handler runs.

Guards operate on RequestContext and return Error on rejection. Apply manually at the top of a handler:

BearerAuth::new("secret").check(&ctx)?;

Re-exports§

pub use crate::resilience::rate_limit::RateLimit;

Structs§

BearerAuth
Minimal Authorization: Bearer <token> guard. Comparison is constant-time.
JwtAuthGuard
Checks that the incoming request carried a valid JWT.
RoleGuard
Checks that the authenticated principal’s "role" claim matches a required value.
SessionAuthGuard
Passes if the request has a loaded server-side session.

Statics§

JWT_AUTH
Ready-to-use singleton for JwtAuthGuard. Import and call:
SESSION_AUTH
Ready-to-use singleton for SessionAuthGuard.

Traits§

Guard