about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVika <vika@fireburn.ru>2022-07-19 04:42:21 +0300
committerVika <vika@fireburn.ru>2022-07-19 04:42:21 +0300
commitfb1f322f188f53e03201eeede479496fd9d0302b (patch)
treeff81ef5814a9dcf4412706a68b0f0c00b9722f30
parenta8f4690c11d31c901e3376308e50a54824f4d04f (diff)
Implement /.well-known/oauth-authorization-server
This may help non-IndieAuth-aware clients to integrate better into the
flow.
-rw-r--r--kittybox-rs/src/indieauth/mod.rs60
-rw-r--r--kittybox-rs/src/main.rs3
2 files changed, 39 insertions, 24 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()
+            ))
+        )
 }
diff --git a/kittybox-rs/src/main.rs b/kittybox-rs/src/main.rs
index 4fb0eec..9e81aad 100644
--- a/kittybox-rs/src/main.rs
+++ b/kittybox-rs/src/main.rs
@@ -155,8 +155,7 @@ async fn main() {
         let media = axum::Router::new()
             .nest("/.kittybox/media", kittybox::media::router(blobstore).layer(axum::Extension(http)));
 
-        /*let indieauth = axum::Router::new()
-            .nest("/.kittybox/indieauth", kittybox::indieauth::router());*/
+        //let indieauth = kittybox::indieauth::router();
 
         let technical = axum::Router::new()
             .route(