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§
Functions§
- init_
jwt_ secret - Initialize the global JWT encoding secret from the configured secret.
This is called automatically by
.add_authentication()on theHostBuilder, 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.