about summary refs log tree commit diff
path: root/kittybox-rs/src/indieauth/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'kittybox-rs/src/indieauth/mod.rs')
-rw-r--r--kittybox-rs/src/indieauth/mod.rs60
1 files changed, 38 insertions, 22 deletions
diff --git a/kittybox-rs/src/indieauth/mod.rs b/kittybox-rs/src/indieauth/mod.rs
index 8100b2a..b22f3ba 100644
--- a/kittybox-rs/src/indieauth/mod.rs
+++ b/kittybox-rs/src/indieauth/mod.rs
@@ -389,27 +389,43 @@ pub fn router<A: AuthBackend>(backend: A) -> axum::Router {
     use axum::routing::{Router, get, post};
 
     Router::new()
+        .nest(
+            "/.kittybox/indieauth",
+            Router::new()
+                .route(
+                    "/auth",
+                    get(authorization_endpoint_get)
+                        .post(authorization_endpoint_post::<A>))
+                .route(
+                    "/token",
+                    post(token_endpoint_post::<A>))
+                .route(
+                    "/token_status",
+                    post(introspection_endpoint_post::<A>))
+                .route(
+                    "/revoke_token",
+                    post(revocation_endpoint_post::<A>))
+                .route(
+                    "/userinfo",
+                    get(userinfo_endpoint_get::<A>))
+                .layer(tower_http::cors::CorsLayer::new()
+                       .allow_methods([
+                           axum::http::Method::GET,
+                           axum::http::Method::POST
+                       ])
+                       .allow_origin(tower_http::cors::Any))
+                .layer(Extension(backend))
+        )
         .route(
-            "/auth",
-            get(authorization_endpoint_get)
-                .post(authorization_endpoint_post::<A>))
-        .route(
-            "/token",
-            post(token_endpoint_post::<A>))
-        .route(
-            "/token_status",
-            post(introspection_endpoint_post::<A>))
-        .route(
-            "/revoke_token",
-            post(revocation_endpoint_post::<A>))
-        .route(
-            "/userinfo",
-            get(userinfo_endpoint_get::<A>))
-        .layer(tower_http::cors::CorsLayer::new()
-               .allow_methods([
-                   axum::http::Method::GET,
-                   axum::http::Method::POST
-               ])
-               .allow_origin(tower_http::cors::Any))
-        .layer(Extension(backend))
+            "/.well-known/oauth-authorization-server",
+            get(|| std::future::ready(
+                (
+                    StatusCode::FOUND,
+                    [
+                        ("Location",
+                         "/.kittybox/indieauth/metadata")
+                    ]
+                ).into_response()
+            ))
+        )
 }