mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 22:09:16 +01:00
refactor(config): 🔥 Remove old oidc section in config
This commit is contained in:
parent
ce781f3336
commit
9f1e89b592
9 changed files with 116 additions and 147 deletions
|
|
@ -110,7 +110,30 @@ const returnError = (context: Context, error: string, description: string) => {
|
|||
|
||||
export default apiRoute((app) =>
|
||||
app.openapi(route, async (context) => {
|
||||
if (config.oidc.forced) {
|
||||
const oidcConfig = config.plugins?.config?.["@versia/openid"] as
|
||||
| {
|
||||
forced: boolean;
|
||||
providers: {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
}[];
|
||||
keys: {
|
||||
private: string;
|
||||
public: string;
|
||||
};
|
||||
}
|
||||
| undefined;
|
||||
|
||||
if (!oidcConfig) {
|
||||
return returnError(
|
||||
context,
|
||||
"invalid_request",
|
||||
"The OpenID Connect plugin is not enabled on this instance. Cannot process login request.",
|
||||
);
|
||||
}
|
||||
|
||||
if (oidcConfig?.forced) {
|
||||
return returnError(
|
||||
context,
|
||||
"invalid_request",
|
||||
|
|
@ -156,7 +179,7 @@ export default apiRoute((app) =>
|
|||
// Try and import the key
|
||||
const privateKey = await crypto.subtle.importKey(
|
||||
"pkcs8",
|
||||
Buffer.from(config.oidc.keys?.private ?? "", "base64"),
|
||||
Buffer.from(oidcConfig?.keys?.private ?? "", "base64"),
|
||||
"Ed25519",
|
||||
false,
|
||||
["sign"],
|
||||
|
|
|
|||
|
|
@ -53,6 +53,17 @@ export default apiRoute((app) =>
|
|||
|
||||
const knownDomainsCount = await Instance.getCount();
|
||||
|
||||
const oidcConfig = config.plugins?.config?.["@versia/openid"] as
|
||||
| {
|
||||
forced: boolean;
|
||||
providers: {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
}[];
|
||||
}
|
||||
| undefined;
|
||||
|
||||
// TODO: fill in more values
|
||||
return context.json({
|
||||
approval_required: false,
|
||||
|
|
@ -94,13 +105,15 @@ export default apiRoute((app) =>
|
|||
},
|
||||
version: "4.3.0-alpha.3+glitch",
|
||||
versia_version: version,
|
||||
// TODO: Put into plugin directly
|
||||
sso: {
|
||||
forced: false,
|
||||
providers: config.oidc.providers.map((p) => ({
|
||||
name: p.name,
|
||||
icon: proxyUrl(p.icon) || undefined,
|
||||
id: p.id,
|
||||
})),
|
||||
forced: oidcConfig?.forced ?? false,
|
||||
providers:
|
||||
oidcConfig?.providers.map((p) => ({
|
||||
name: p.name,
|
||||
icon: proxyUrl(p.icon) || undefined,
|
||||
id: p.id,
|
||||
})) ?? [],
|
||||
},
|
||||
contact_account: contactAccount?.toApi() || undefined,
|
||||
} satisfies Record<string, unknown> & {
|
||||
|
|
|
|||
|
|
@ -133,6 +133,17 @@ export default apiRoute((app) =>
|
|||
30 * 24 * 60 * 60 * 1000,
|
||||
);
|
||||
|
||||
const oidcConfig = config.plugins?.config?.["@versia/openid"] as
|
||||
| {
|
||||
forced: boolean;
|
||||
providers: {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
}[];
|
||||
}
|
||||
| undefined;
|
||||
|
||||
// TODO: fill in more values
|
||||
return context.json({
|
||||
domain: new URL(config.http.base_url).hostname,
|
||||
|
|
@ -216,12 +227,13 @@ export default apiRoute((app) =>
|
|||
hint: "",
|
||||
})),
|
||||
sso: {
|
||||
forced: false,
|
||||
providers: config.oidc.providers.map((p) => ({
|
||||
name: p.name,
|
||||
icon: proxyUrl(p.icon) ?? "",
|
||||
id: p.id,
|
||||
})),
|
||||
forced: oidcConfig?.forced ?? false,
|
||||
providers:
|
||||
oidcConfig?.providers.map((p) => ({
|
||||
name: p.name,
|
||||
icon: proxyUrl(p.icon) ?? "",
|
||||
id: p.id,
|
||||
})) ?? [],
|
||||
},
|
||||
});
|
||||
}),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue