feat: oidc

This commit is contained in:
DecDuck
2025-05-07 22:14:04 +10:00
parent e8633ceca2
commit 19ff73cc30
16 changed files with 533 additions and 146 deletions

View File

@ -0,0 +1,9 @@
import { enabledAuthManagers } from "~/server/plugins/04.auth-init";
export default defineEventHandler((h3) => {
const authManagers = Object.entries(enabledAuthManagers)
.filter((e) => !!e[1])
.map((e) => e[0]);
return authManagers;
});

View File

@ -7,6 +7,7 @@ import {
checkHashBcrypt,
} from "~/server/internal/security/simple";
import sessionHandler from "~/server/internal/session";
import { enabledAuthManagers } from "~/server/plugins/04.auth-init";
const signinValidator = type({
username: "string",
@ -15,6 +16,12 @@ const signinValidator = type({
});
export default defineEventHandler(async (h3) => {
if (!enabledAuthManagers.simple)
throw createError({
statusCode: 403,
statusMessage: "Sign in method not enabled",
});
const body = signinValidator(await readBody(h3));
if (body instanceof type.errors) {
// hover out.summary to see validation errors