fix(auth): fail closed configuration compatibility

This commit is contained in:
2026-08-16 17:35:40 +02:00
parent a66ef58766
commit e54ce15426
7 changed files with 120 additions and 13 deletions
+1 -2
View File
@@ -1,12 +1,11 @@
import type { FastifyRequest, FastifyReply } from "fastify";
import { localPrincipal, type PrincipalContext, upstreamPrincipal } from "./principal.js";
import type { AuthMode } from "./types.js";
declare module "fastify" {
interface FastifyRequest { principal?: PrincipalContext }
}
export function authPreHandler(mode: AuthMode) {
export function authPreHandler(mode: "none" | "mock" | "upstream") {
return async (req: FastifyRequest, reply: FastifyReply) => {
if (mode === "none") {
req.principal = localPrincipal();