mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-09 20:12:10 +10:00
feat: add oidc to admin panel
This commit is contained in:
@ -27,7 +27,6 @@ export default defineNitroPlugin(async (_nitro) => {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Add providers based on their position in the application settings
|
||||
const configuredProviderList =
|
||||
await applicationSettings.get("metadataProviders");
|
||||
|
||||
@ -1,24 +1,25 @@
|
||||
import { AuthMec } from "@prisma/client";
|
||||
import { OIDCManager } from "../internal/oidc";
|
||||
|
||||
export const enabledAuthManagers: {
|
||||
simple: boolean;
|
||||
oidc: OIDCManager | undefined;
|
||||
[AuthMec.Simple]: boolean;
|
||||
[AuthMec.OpenID]: OIDCManager | undefined;
|
||||
} = {
|
||||
simple: false,
|
||||
oidc: undefined,
|
||||
[AuthMec.Simple]: false,
|
||||
[AuthMec.OpenID]: undefined,
|
||||
};
|
||||
|
||||
const initFunctions: {
|
||||
[K in keyof typeof enabledAuthManagers]: () => Promise<unknown>;
|
||||
} = {
|
||||
oidc: OIDCManager.prototype.create,
|
||||
simple: async () => {
|
||||
[AuthMec.OpenID]: OIDCManager.prototype.create,
|
||||
[AuthMec.Simple]: async () => {
|
||||
const disabled = process.env.DISABLE_SIMPLE_AUTH as string | undefined;
|
||||
return !disabled;
|
||||
},
|
||||
};
|
||||
|
||||
export default defineNitroPlugin(async (_nitro) => {
|
||||
export default defineNitroPlugin(async () => {
|
||||
for (const [key, init] of Object.entries(initFunctions)) {
|
||||
try {
|
||||
const object = await init();
|
||||
@ -32,7 +33,7 @@ export default defineNitroPlugin(async (_nitro) => {
|
||||
}
|
||||
|
||||
// Add every other auth mechanism here, and fall back to simple if none of them are enabled
|
||||
if (!enabledAuthManagers.oidc) {
|
||||
enabledAuthManagers.simple = true;
|
||||
if (!enabledAuthManagers[AuthMec.OpenID]) {
|
||||
enabledAuthManagers[AuthMec.Simple] = true;
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user