mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-13 16:22:39 +10:00
23 lines
730 B
TypeScript
23 lines
730 B
TypeScript
import { AuthMec } from "~/prisma/client/enums";
|
|
import aclManager from "~/server/internal/acls";
|
|
import authManager from "~/server/internal/auth";
|
|
|
|
/**
|
|
* Fetches all the enabled authentication mechanisms on this instance, and their configuration, if enabled.
|
|
*/
|
|
export default defineEventHandler(async (h3) => {
|
|
const allowed = await aclManager.allowSystemACL(h3, ["auth:read", "setup"]);
|
|
if (!allowed) throw createError({ statusCode: 403 });
|
|
|
|
const enabledAuthManagers = authManager.getAuthProviders();
|
|
|
|
const authData = {
|
|
[AuthMec.Simple]: enabledAuthManagers.Simple,
|
|
[AuthMec.OpenID]:
|
|
enabledAuthManagers.OpenID &&
|
|
enabledAuthManagers.OpenID.generateConfiguration(),
|
|
};
|
|
|
|
return authData;
|
|
});
|