feat: Security CSRF Fix, Logout optimierung, Footer Anpassung, Rechtstexteanpassung
Docker Image bauen und veroeffentlichen / build-and-push (push) Failing after 1m33s
Docker Image bauen und veroeffentlichen / build-and-push (push) Failing after 1m33s
This commit is contained in:
1 parent
0753a3bc8a
commit
4d3100e9ba
28 files changed
+802
-121
No files matched your search
@@ -8,11 +8,13 @@ import {
|
||||
TWO_FACTOR_CHALLENGE_COOKIE,
|
||||
TWO_FACTOR_SETUP_COOKIE,
|
||||
TWO_FACTOR_BACKUP_CODES_COOKIE,
|
||||
ENTRA_OAUTH_COOKIE,
|
||||
signSessionToken,
|
||||
verifySessionToken,
|
||||
verifyTwoFactorChallenge,
|
||||
verifyTwoFactorSetup,
|
||||
verifyTwoFactorBackupCodesDisplay,
|
||||
verifyEntraOAuthState,
|
||||
type SessionRole,
|
||||
} from "@/lib/session";
|
||||
import type { Customer } from "@/generated/prisma/client";
|
||||
@@ -183,3 +185,33 @@ export async function clearTwoFactorBackupCodesDisplayCookie(): Promise<void> {
|
||||
const cookieStore = await cookies();
|
||||
cookieStore.delete(TWO_FACTOR_BACKUP_CODES_COOKIE);
|
||||
}
|
||||
|
||||
/** Setzt das kurzlebige Cookie mit PKCE-code_verifier + CSRF-state fuer den laufenden Entra-ID-SSO-Versuch. */
|
||||
export async function setEntraOAuthCookie(token: string): Promise<void> {
|
||||
const cookieStore = await cookies();
|
||||
cookieStore.set(ENTRA_OAUTH_COOKIE, token, {
|
||||
httpOnly: true,
|
||||
secure: process.env.NODE_ENV === "production",
|
||||
// "lax" reicht hier: der Redirect zurueck von login.microsoftonline.com
|
||||
// ist eine Top-Level-GET-Navigation, die "lax" bei Cross-Site-Redirects
|
||||
// ausdruecklich mitsendet (anders als bei einem POST/Formular-Cross-Site-
|
||||
// Request, wo "lax" das Cookie zurueckhaelt).
|
||||
sameSite: "lax",
|
||||
path: "/",
|
||||
maxAge: 10 * 60,
|
||||
});
|
||||
}
|
||||
|
||||
/** Liest state + code_verifier des laufenden Entra-ID-SSO-Versuchs, ohne das Cookie zu loeschen. */
|
||||
export async function getEntraOAuthCookie(): Promise<{ state: string; codeVerifier: string } | null> {
|
||||
const cookieStore = await cookies();
|
||||
const token = cookieStore.get(ENTRA_OAUTH_COOKIE)?.value;
|
||||
if (!token) return null;
|
||||
return verifyEntraOAuthState(token);
|
||||
}
|
||||
|
||||
/** Einmal verwendet (erfolgreich oder nicht) wird das Cookie sofort geloescht — kein Replay eines alten code_verifier/state-Paars. */
|
||||
export async function clearEntraOAuthCookie(): Promise<void> {
|
||||
const cookieStore = await cookies();
|
||||
cookieStore.delete(ENTRA_OAUTH_COOKIE);
|
||||
}
|
||||
Reference in new issue
Block a user