-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy path+server.ts
More file actions
35 lines (34 loc) · 1005 Bytes
/
+server.ts
File metadata and controls
35 lines (34 loc) · 1005 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { base } from "$app/paths";
import { OIDConfig } from "$lib/server/auth";
import { config } from "$lib/server/config";
/**
* See https://datatracker.ietf.org/doc/draft-ietf-oauth-client-id-metadata-document/
*/
export const GET = ({ url }) => {
if (!OIDConfig.CLIENT_ID) {
return new Response("Client ID not found", { status: 404 });
}
if (OIDConfig.CLIENT_ID !== "__CIMD__") {
return new Response(
`Client ID is manually set to something other than '__CIMD__': ${OIDConfig.CLIENT_ID}`,
{
status: 404,
}
);
}
return new Response(
JSON.stringify({
client_id: new URL(url, config.PUBLIC_ORIGIN || url.origin).toString(),
client_name: config.PUBLIC_APP_NAME,
client_uri: `${config.PUBLIC_ORIGIN || url.origin}${base}`,
redirect_uris: [new URL("/login/callback", config.PUBLIC_ORIGIN || url.origin).toString()],
token_endpoint_auth_method: "none",
scopes: OIDConfig.SCOPES,
}),
{
headers: {
"Content-Type": "application/json",
},
}
);
};