mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 13:59:16 +01:00
refactor(api): ♻️ More OpenAPI refactoring work
This commit is contained in:
parent
6d9e385a04
commit
5aa1c4e625
35 changed files with 4883 additions and 1815 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import { apiRoute, applyConfig } from "@/api";
|
||||
import { createRoute, z } from "@hono/zod-openapi";
|
||||
import { config } from "~/packages/config-manager";
|
||||
|
||||
export const meta = applyConfig({
|
||||
|
|
@ -13,21 +14,56 @@ export const meta = applyConfig({
|
|||
route: "/.well-known/openid-configuration",
|
||||
});
|
||||
|
||||
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()),
|
||||
}),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export default apiRoute((app) =>
|
||||
app.on(meta.allowedMethods, meta.route, (context) => {
|
||||
app.openapi(route, (context) => {
|
||||
const baseUrl = new URL(config.http.base_url);
|
||||
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"],
|
||||
});
|
||||
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,
|
||||
);
|
||||
}),
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue