Expand description
JWT authentication service — sign, decode, and validate JSON Web Tokens.
§Usage
Provide a JwtService instance in an ArclyPlugin::on_init:
ⓘ
ctx.provide(JwtService::new(JwtConfig {
secret: "change-in-prod".to_string(),
access_ttl_secs: 900,
refresh_ttl_secs: 604_800,
..Default::default()
}));Once provided, the HTTP and WebSocket boundaries automatically decode the
Authorization: Bearer <token> header and populate RequestContext::claims()
on every request — no per-handler boilerplate needed. Protect routes with
JWT_AUTH.check(&ctx)? or RoleGuard::require("admin").check(&ctx)?.
Structs§
- JwtConfig
- JwtService
- Signs and validates JWTs. Provide this into the DI container so the framework
boundaries (
boundary.rs,ws.rs) can auto-populateRequestContext::claims()on every incoming request. - JwtSign
Error - Configuration for
JwtService. Build once at startup and provide via DI. Token signing failed — malformed key material (typically a bad rotation payload). Map to a 500 at the route; the process must keep serving.
Functions§
- decode_
bearer_ token - Extract and decode an access Bearer token from request headers.