Skip to content

mozilla-iam/dino-park-gate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DinoPark Gate (controlling Dinos since 2019)

Build Status

A basic authentication middleware for actix-web

use actix_web::{web, App, HttpRequest, HttpServer, Responder};
use dino_park_gate::provider::Provider;
use dino_park_gate::simple::SimpleAuth;

async fn root(_: HttpRequest) -> impl Responder {
    "Authorized!"
}

#[actix_rt::main]
async fn main() -> std::io::Result<()> {
    let provider = Provider::from_issuer("https://auth.mozilla.auth0.com/")
        .await
        .unwrap();
    HttpServer::new(move || {
        let auth = SimpleAuth {
            checker: provider.clone(),
            validation_options: Default::default(),
        };
        App::new().wrap(auth).service(web::resource("/").to(root))
    })
    .workers(1)
    .bind("127.0.0.1:8000")?
    .run()
    .await
}

About

DinoPark Gate (controlling Dinos since 2019)

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages