2024-12-30 20:18:48 +01:00
|
|
|
import { apiRoute } from "@/api";
|
2024-09-16 15:29:09 +02:00
|
|
|
import { createRoute, z } from "@hono/zod-openapi";
|
2024-05-29 02:59:49 +02:00
|
|
|
import { config } from "~/packages/config-manager";
|
2024-04-18 10:42:12 +02:00
|
|
|
|
2024-09-16 15:29:09 +02:00
|
|
|
const route = createRoute({
|
|
|
|
|
method: "get",
|
|
|
|
|
path: "/.well-known/openid-configuration",
|
|
|
|
|
summary: "OpenID Configuration",
|
|
|
|
|
responses: {
|
|
|
|
|
200: {
|
|
|
|
|
description: "OpenID Configuration",
|
|
|
|
|
content: {
|
|
|
|
|
"application/json": {
|
|
|
|
|
schema: z.object({
|
|
|
|
|
issuer: z.string(),
|
|
|
|
|
authorization_endpoint: z.string(),
|
|
|
|
|
token_endpoint: z.string(),
|
|
|
|
|
userinfo_endpoint: z.string(),
|
|
|
|
|
jwks_uri: z.string(),
|
|
|
|
|
response_types_supported: z.array(z.string()),
|
|
|
|
|
subject_types_supported: z.array(z.string()),
|
|
|
|
|
id_token_signing_alg_values_supported: z.array(
|
|
|
|
|
z.string(),
|
|
|
|
|
),
|
|
|
|
|
scopes_supported: z.array(z.string()),
|
|
|
|
|
token_endpoint_auth_methods_supported: z.array(
|
|
|
|
|
z.string(),
|
|
|
|
|
),
|
|
|
|
|
claims_supported: z.array(z.string()),
|
|
|
|
|
}),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
2024-08-19 20:06:38 +02:00
|
|
|
export default apiRoute((app) =>
|
2024-09-16 15:29:09 +02:00
|
|
|
app.openapi(route, (context) => {
|
2025-02-13 01:31:15 +01:00
|
|
|
const baseUrl = config.http.base_url;
|
2024-09-16 15:29:09 +02:00
|
|
|
return context.json(
|
|
|
|
|
{
|
|
|
|
|
issuer: baseUrl.origin.toString(),
|
|
|
|
|
authorization_endpoint: `${baseUrl.origin}/oauth/authorize`,
|
|
|
|
|
token_endpoint: `${baseUrl.origin}/oauth/token`,
|
|
|
|
|
userinfo_endpoint: `${baseUrl.origin}/api/v1/accounts/verify_credentials`,
|
|
|
|
|
jwks_uri: `${baseUrl.origin}/.well-known/jwks`,
|
|
|
|
|
response_types_supported: ["code"],
|
|
|
|
|
subject_types_supported: ["public"],
|
|
|
|
|
id_token_signing_alg_values_supported: ["EdDSA"],
|
|
|
|
|
scopes_supported: ["openid", "profile", "email"],
|
|
|
|
|
token_endpoint_auth_methods_supported: ["client_secret_basic"],
|
|
|
|
|
claims_supported: ["sub"],
|
|
|
|
|
},
|
|
|
|
|
200,
|
|
|
|
|
);
|
2024-08-19 20:06:38 +02:00
|
|
|
}),
|
|
|
|
|
);
|