From fb1f322f188f53e03201eeede479496fd9d0302b Mon Sep 17 00:00:00 2001 From: Vika Date: Tue, 19 Jul 2022 04:42:21 +0300 Subject: Implement /.well-known/oauth-authorization-server This may help non-IndieAuth-aware clients to integrate better into the flow. --- kittybox-rs/src/indieauth/mod.rs | 60 +++++++++++++++++++++++++--------------- kittybox-rs/src/main.rs | 3 +- 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(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::)) + .route( + "/token", + post(token_endpoint_post::)) + .route( + "/token_status", + post(introspection_endpoint_post::)) + .route( + "/revoke_token", + post(revocation_endpoint_post::)) + .route( + "/userinfo", + get(userinfo_endpoint_get::)) + .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::)) - .route( - "/token", - post(token_endpoint_post::)) - .route( - "/token_status", - post(introspection_endpoint_post::)) - .route( - "/revoke_token", - post(revocation_endpoint_post::)) - .route( - "/userinfo", - get(userinfo_endpoint_get::)) - .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( -- cgit 1.4.1