Crates.io | actix-jwt-validator-middleware |
lib.rs | actix-jwt-validator-middleware |
version | 0.3.0 |
source | src |
created_at | 2021-04-10 12:38:03.784254 |
updated_at | 2021-09-15 15:03:54.761155 |
description | Middleware and extractor for JWT bearer tokens for the actix-web framework |
homepage | https://github.com/jofas/actix_jwt_validator_middleware |
repository | https://github.com/jofas/actix_jwt_validator_middleware |
max_upload_size | |
id | 381678 |
size | 8,611 |
Simple actix
middleware that takes a JWT
bearer token from the
authorization
HTTP header and validates it against some JWKS
.
use actix_web::{HttpServer, App};
use actix_jwt_validator_middleware::{jwt_validator, init_key_set};
async fn index() -> &'static str {
"Welcome!"
}
#[actix_web::main]
async fn main() -> std::io::Result<()> {
let key_set = init_key_set("url-to-your-certification-endpoint")
.await
.unwrap();
HttpServer::new(move || {
App::new()
.data(key_set.clone())
.wrap(jwt_validator())
.route("/index.html", web::get().to(index))
})
.bind("0.0.0.0:8080")?
.run()
.await
}
jwk_client
one with Arc
to
make referencing thread-safe