Skip to main content

Module auth_jwt

Module auth_jwt 

Source
Expand description

JWT authentication module for the rust-webx framework.

Provides JwtAuth —an IAuthenticationHandler implementation that reads a Bearer token from the Authorization header and validates it using the jsonwebtoken crate.

§Example

use rust_webx_host::auth_jwt::{JwtAuth, jwt_middleware};
use jsonwebtoken::{DecodingKey, Validation};

let auth = JwtAuth::new(
    DecodingKey::from_secret(b"my-secret"),
    Validation::default(),
);
let middleware = jwt_middleware(Arc::new(auth));

Structs§

JwtAuth
JWT-based authentication handler.
JwtClaims
Claims extracted from a JWT token.

Functions§

init_jwt_secret
Initialize the global JWT encoding secret from the configured secret. This is called automatically by .add_authentication() on the HostBuilder, but can also be called manually if needed.
jwt_middleware
Create a JWT authentication middleware from an authentication handler.
jwt_secret
Retrieve the global JWT encoding secret previously set via init_jwt_secret.