Zugangs-Sperre: Code wird nach dem Schliessen des Browsers wieder gefragt
Build & Deploy / deploy (push) Waiting to run
Build & Deploy / deploy (push) Waiting to run
Sitzungs-Cookie ohne maxAge/expires statt 90-Tage-Cookie (auch fuer die zweite Verwaltungs-Schranke); zusaetzlich Notbremse von 12 Stunden im signierten Token, falls ein Browser sehr lange offen bleibt. Kundenkonten (customer-auth.js, 30 Tage) bleiben bewusst unveraendert.
This commit is contained in:
@@ -12,10 +12,9 @@
|
||||
- API-Routen bekommen bei fehlender Sitzung 401-JSON statt HTML-Redirect.
|
||||
===================================================================== */
|
||||
|
||||
import { COOKIE_NAME, ROLE_COOKIE_NAME, SESSION_TAGE, signSession, verifySession } from "../lib/auth.js";
|
||||
import { COOKIE_NAME, ROLE_COOKIE_NAME, signSession, verifySession } from "../lib/auth.js";
|
||||
import {
|
||||
VERWALTUNG_COOKIE_NAME,
|
||||
VERWALTUNG_SESSION_STUNDEN,
|
||||
signVerwaltungSession,
|
||||
verifyVerwaltungSession,
|
||||
} from "../lib/verwaltung-auth.js";
|
||||
@@ -44,9 +43,9 @@ export async function gateAuthHandler(req, res) {
|
||||
}
|
||||
|
||||
const session = await signSession(role, process.env.SITE_ACCESS_SECRET);
|
||||
const maxAge = SESSION_TAGE * 24 * 60 * 60 * 1000;
|
||||
res.cookie(COOKIE_NAME, session, { path: "/", maxAge, httpOnly: true, secure: true, sameSite: "lax" });
|
||||
res.cookie(ROLE_COOKIE_NAME, role, { path: "/", maxAge, secure: true, sameSite: "lax" });
|
||||
// Bewusst OHNE maxAge/expires → reines Sitzungs-Cookie, verfällt beim Schließen des Browsers.
|
||||
res.cookie(COOKIE_NAME, session, { path: "/", httpOnly: true, secure: true, sameSite: "lax" });
|
||||
res.cookie(ROLE_COOKIE_NAME, role, { path: "/", secure: true, sameSite: "lax" });
|
||||
return res.json({ ok: true, next });
|
||||
}
|
||||
|
||||
@@ -62,8 +61,8 @@ export async function verwaltungAuthHandler(req, res) {
|
||||
}
|
||||
|
||||
const session = await signVerwaltungSession(process.env.VERWALTUNG_SESSION_SECRET);
|
||||
const maxAge = VERWALTUNG_SESSION_STUNDEN * 60 * 60 * 1000;
|
||||
res.cookie(VERWALTUNG_COOKIE_NAME, session, { path: "/", maxAge, httpOnly: true, secure: true, sameSite: "lax" });
|
||||
// Ebenfalls reines Sitzungs-Cookie (siehe gateAuthHandler oben).
|
||||
res.cookie(VERWALTUNG_COOKIE_NAME, session, { path: "/", httpOnly: true, secure: true, sameSite: "lax" });
|
||||
return res.json({ ok: true, next });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user