summaryrefslogtreecommitdiff
path: root/src/demo/main.rs
diff options
context:
space:
mode:
authorJesse Morgan <jesse@jesterpm.net>2022-03-23 08:22:38 -0700
committerJesse Morgan <jesse@jesterpm.net>2022-03-23 08:22:38 -0700
commit3605650a90c0710aeee93930ba2622bf00a88b70 (patch)
tree80344b3717c3483cb1b07c9d1f7c8b6aa2a3199a /src/demo/main.rs
parent5ac0b170be23a2af4b93cb2287da1f7393db8165 (diff)
Add support for token extensionsv0.2.0
Diffstat (limited to 'src/demo/main.rs')
-rw-r--r--src/demo/main.rs47
1 files changed, 0 insertions, 47 deletions
diff --git a/src/demo/main.rs b/src/demo/main.rs
deleted file mode 100644
index f598b84..0000000
--- a/src/demo/main.rs
+++ /dev/null
@@ -1,47 +0,0 @@
-use actix_middleware_rfc7662::{
- AnyScope, RequireAuthorization, RequireAuthorizationConfig, RequireScope,
-};
-use actix_web::{get, HttpResponse, HttpServer, Responder};
-
-#[get("/read")]
-async fn handle_read(_auth: RequireAuthorization<AnyScope>) -> impl Responder {
- HttpResponse::Ok().body("Success!\n")
-}
-
-struct WriteScope;
-impl RequireScope for WriteScope {
- fn scope() -> &'static str {
- "write"
- }
-}
-
-#[get("/write")]
-async fn handle_write(_auth: RequireAuthorization<WriteScope>) -> impl Responder {
- HttpResponse::Ok().body("Success!\n")
-}
-
-#[actix_web::main]
-async fn main() -> std::io::Result<()> {
- let bind = std::env::var("BIND").unwrap_or_else(|_| "127.0.0.1:8182".to_string());
-
- let oauth_config = RequireAuthorizationConfig::new(
- "cid1".to_string(),
- Some("cs1".to_string()),
- "https://cadmium.jesterpm.net/oauth/authorize"
- .parse()
- .expect("invalid url"),
- "https://cadmium.jesterpm.net/oauth/introspect"
- .parse()
- .expect("invalid url"),
- );
-
- HttpServer::new(move || {
- actix_web::App::new()
- .app_data(oauth_config.clone())
- .service(handle_read)
- .service(handle_write)
- })
- .bind(bind)?
- .run()
- .await
-}