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 +++++++++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 22 deletions(-) (limited to 'kittybox-rs/src/indieauth') 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() + )) + ) } -- cgit 1.4.1