auth: JWT valid until logout (drop 8h expiry)

Booth reality breaks a fixed clock (relief late/absent, forced double shifts),
and a shift is a separate explicit boundary. Drop expiresIn from the global jwt
config and from login; the token carries no exp. Cookie maxAge = 30 days so a
browser restart doesn't log out an active operator; logout still clears it.
This commit is contained in:
2026-06-15 19:15:53 +02:00
parent 2a36830880
commit a8c6d6e714
4 changed files with 30 additions and 14 deletions
+11 -5
View File
@@ -18,9 +18,15 @@ export const TOKEN_COOKIE = "parking_token";
export const CSRF_COOKIE = "parking_csrf";
export const CSRF_HEADER = "x-csrf-token";
/** Token lifetime, also used as the cookie maxAge. */
export const TOKEN_TTL = "8h";
export const TOKEN_TTL_SECONDS = 8 * 60 * 60;
// Session lifetime: the JWT has NO expiry — a login is valid until explicit
// logout. Booth reality breaks any fixed clock (relief late/absent, forced double
// shifts), and a shift is a separate explicit boundary, not the token's lifetime.
// See wiki/entities/local-jwt-auth.md + wiki/concepts/shift.md.
//
// The cookie still needs a maxAge so it survives a browser restart (a session
// cookie would log out an active operator on browser close — the opposite of
// "until logout"). Use a long fixed window; the server clears it on logout.
export const COOKIE_MAX_AGE_SECONDS = 30 * 24 * 60 * 60; // 30 days
/**
* Resolve the JWT signing secret, refusing to start without a strong one.
@@ -55,7 +61,7 @@ export function setAuthCookies(reply: FastifyReply, jwt: string, csrf: string):
sameSite: "strict",
secure,
path: "/",
maxAge: TOKEN_TTL_SECONDS,
maxAge: COOKIE_MAX_AGE_SECONDS,
});
// Readable by JS so the SPA can echo it back in the CSRF header (double-submit).
reply.setCookie(CSRF_COOKIE, csrf, {
@@ -63,7 +69,7 @@ export function setAuthCookies(reply: FastifyReply, jwt: string, csrf: string):
sameSite: "strict",
secure,
path: "/",
maxAge: TOKEN_TTL_SECONDS,
maxAge: COOKIE_MAX_AGE_SECONDS,
});
}