mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-16 17:51:17 +10:00
* feat: database redist support * feat: rearchitecture of database schemas, migration reset, and #180 * feat: import redists * fix: giantbomb logging bug * feat: partial user platform support + statusMessage -> message * feat: add user platform filters to store view * fix: sanitize svg uploads ... copilot suggested this I feel dirty. * feat: beginnings of platform & redist management * feat: add server side redist patching * fix: update drop-base commit * feat: import of custom platforms & file extensions * fix: redelete platform * fix: remove platform * feat: uninstall commands, new R UI * checkpoint: before migrating to nuxt v4 * update to nuxt 4 * fix: fixes for Nuxt v4 update * fix: remaining type issues * feat: initial feedback to import other kinds of versions * working commit * fix: lint * feat: redist import
64 lines
1.6 KiB
TypeScript
64 lines
1.6 KiB
TypeScript
import { AuthMec } from "~~/prisma/client/enums";
|
|
import { OIDCManager } from "./oidc";
|
|
import { logger } from "~~/server/internal/logging";
|
|
|
|
class AuthManager {
|
|
private authProviders: {
|
|
[AuthMec.Simple]: boolean;
|
|
[AuthMec.OpenID]: OIDCManager | undefined;
|
|
} = {
|
|
[AuthMec.Simple]: false,
|
|
[AuthMec.OpenID]: undefined,
|
|
};
|
|
|
|
private initFuncs: {
|
|
[K in keyof typeof this.authProviders]: () => Promise<unknown>;
|
|
} = {
|
|
[AuthMec.OpenID]: OIDCManager.prototype.create,
|
|
[AuthMec.Simple]: async () => {
|
|
const disabled = process.env.DISABLE_SIMPLE_AUTH as string | undefined;
|
|
return !disabled;
|
|
},
|
|
};
|
|
|
|
constructor() {
|
|
logger.info("AuthManager initialized");
|
|
}
|
|
|
|
async init() {
|
|
for (const [key, init] of Object.entries(this.initFuncs)) {
|
|
try {
|
|
const object = await init();
|
|
if (!object) break;
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
(this.authProviders as any)[key] = object;
|
|
logger.info(`enabled auth: ${key}`);
|
|
} catch (e) {
|
|
logger.warn(e);
|
|
}
|
|
}
|
|
|
|
// Add every other auth mechanism here, and fall back to simple if none of them are enabled
|
|
if (!this.authProviders[AuthMec.OpenID]) {
|
|
this.authProviders[AuthMec.Simple] = true;
|
|
}
|
|
}
|
|
|
|
getAuthProviders() {
|
|
return this.authProviders;
|
|
}
|
|
|
|
getEnabledAuthProviders() {
|
|
const authManagers = Object.entries(this.authProviders)
|
|
.filter((e) => !!e[1])
|
|
.map((e) => e[0]);
|
|
|
|
return authManagers;
|
|
}
|
|
}
|
|
|
|
const authManager = new AuthManager();
|
|
export default authManager;
|
|
|
|
export * from "./passwordHash";
|