Skip to main content

Module jwt

Module jwt 

Source
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
Configuration for JwtService. Build once at startup and provide via DI.
JwtService
Signs and validates JWTs. Provide this into the DI container so the framework boundaries (boundary.rs, ws.rs) can auto-populate RequestContext::claims() on every incoming request.

Functions§

decode_bearer_token
Extract and decode an access Bearer token from request headers.