Enrollment + almost all auth

This commit is contained in:
mdares
2026-01-03 20:18:39 +00:00
parent 0ad2451dd4
commit a0ed517047
40 changed files with 3559 additions and 31 deletions

20
lib/auth/sessionCookie.ts Normal file
View File

@@ -0,0 +1,20 @@
export const COOKIE_NAME = "mis_session";
export const SESSION_DAYS = 7;
export function isSecureRequest(req: Request) {
const forwardedProto = req.headers.get("x-forwarded-proto");
if (forwardedProto) {
return forwardedProto.split(",")[0].trim() === "https";
}
return new URL(req.url).protocol === "https:";
}
export function buildSessionCookieOptions(req: Request) {
return {
httpOnly: true,
sameSite: "lax" as const,
secure: isSecureRequest(req),
path: "/",
maxAge: SESSION_DAYS * 24 * 60 * 60,
};
}