Integrating with Rust Actix-web API
Using authaction-rust-sdk
Section titled “Using authaction-rust-sdk”authaction = { version = "0.1", features = ["actix"] }use actix_web::{web, App, HttpServer};use authaction::{Verifier, actix::AuthenticatedUser};
async fn protected(user: AuthenticatedUser) -> impl Responder { HttpResponse::Ok().json(serde_json::json!({ "sub": user.claims.sub }))}
#[actix_web::main]async fn main() -> std::io::Result<()> { let verifier = Verifier::new( &std::env::var("AUTHACTION_DOMAIN").unwrap(), &std::env::var("AUTHACTION_AUDIENCE").unwrap(), ); HttpServer::new(move || { App::new() .app_data(web::Data::new(verifier.clone())) .route("/protected", web::get().to(protected)) }) .bind("0.0.0.0:8080")?.run().await}Full SDK reference: github.com/authaction/authaction-rust-sdk