forked from
smokesignal.events/smokesignal
i18n+filtering fork - fluent-templates v2
1use anyhow::Result;
2use axum::{extract::State, response::IntoResponse, Json};
3use serde::Serialize;
4
5use super::{context::WebContext, errors::WebError};
6
7#[derive(Serialize)]
8struct AuthMetadata {
9 client_id: String,
10 dpop_bound_access_tokens: bool,
11 application_type: &'static str,
12 redirect_uris: Vec<String>,
13 client_uri: String,
14 grant_types: Vec<&'static str>,
15 response_types: Vec<&'static str>,
16 scope: &'static str,
17 client_name: &'static str,
18 token_endpoint_auth_method: &'static str,
19 jwks_uri: String,
20 logo_uri: String,
21 tos_uri: &'static str,
22 policy_uri: &'static str,
23 subject_type: &'static str,
24 token_endpoint_auth_signing_alg: &'static str,
25}
26
27pub async fn handle_oauth_metadata(
28 State(web_context): State<WebContext>,
29) -> Result<impl IntoResponse, WebError> {
30 tracing::warn!("handle_oauth_metadata");
31
32 let client_id = format!(
33 "https://{}/oauth/client-metadata.json",
34 web_context.config.external_base
35 );
36 let redirect_uris = vec![format!(
37 "https://{}/oauth/callback",
38 web_context.config.external_base
39 )];
40 let jwks_uri = format!(
41 "https://{}/.well-known/jwks.json",
42 web_context.config.external_base
43 );
44
45 let resp = AuthMetadata {
46 application_type: "web",
47 client_id,
48 client_name: "Smoke Signal",
49 client_uri: format!("https://{}", web_context.config.external_base),
50 dpop_bound_access_tokens: true,
51 grant_types: vec!["authorization_code", "refresh_token"],
52 jwks_uri,
53 logo_uri: format!(
54 "https://{}/logo-160x160x.png",
55 web_context.config.external_base
56 ),
57 policy_uri: "https://docs.smokesignal.events/docs/about/privacy/",
58 redirect_uris,
59 response_types: vec!["code"],
60 scope: "atproto transition:generic",
61 token_endpoint_auth_method: "private_key_jwt",
62 token_endpoint_auth_signing_alg: "ES256",
63 subject_type: "public",
64 tos_uri: "https://docs.smokesignal.events/docs/about/terms/",
65 };
66 Ok(Json(resp))
67}