mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-13 16:22:39 +10:00
feat: add oidc to admin panel
This commit is contained in:
@ -1,14 +1,15 @@
|
||||
import type { AuthMec } from "@prisma/client";
|
||||
import { AuthMec } from "@prisma/client";
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import { applicationSettings } from "~/server/internal/config/application-configuration";
|
||||
import { enabledAuthManagers } from "~/server/plugins/04.auth-init";
|
||||
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const allowed = await aclManager.allowSystemACL(h3, ["auth:read"]);
|
||||
if (!allowed) throw createError({ statusCode: 403 });
|
||||
|
||||
const enabledMechanisms: AuthMec[] = await applicationSettings.get(
|
||||
"enabledAuthencationMechanisms",
|
||||
);
|
||||
const authData = {
|
||||
[AuthMec.Simple]: enabledAuthManagers.Simple,
|
||||
[AuthMec.OpenID]: enabledAuthManagers.OpenID && enabledAuthManagers.OpenID.generateConfiguration(),
|
||||
}
|
||||
|
||||
return enabledMechanisms;
|
||||
return authData;
|
||||
});
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { enabledAuthManagers } from "~/server/plugins/04.auth-init";
|
||||
|
||||
export default defineEventHandler((h3) => {
|
||||
export default defineEventHandler(() => {
|
||||
const authManagers = Object.entries(enabledAuthManagers)
|
||||
.filter((e) => !!e[1])
|
||||
.map((e) => e[0]);
|
||||
|
||||
@ -16,7 +16,7 @@ const signinValidator = type({
|
||||
});
|
||||
|
||||
export default defineEventHandler(async (h3) => {
|
||||
if (!enabledAuthManagers.simple)
|
||||
if (!enabledAuthManagers.Simple)
|
||||
throw createError({
|
||||
statusCode: 403,
|
||||
statusMessage: "Sign in method not enabled",
|
||||
|
||||
Reference in New Issue
Block a user