feat(frontend): encrypt session cookie (JWE) and auto-refresh access token

This commit is contained in:
2026-07-05 23:41:49 +02:00
parent e11db5263b
commit 46c7d5dbc7
3 changed files with 67 additions and 16 deletions
+2 -7
View File
@@ -4,6 +4,7 @@ import type { RequestHandler } from './$types';
import {
getOidcConfig,
encodeSession,
sessionCookieOptions,
type Session,
SESSION_COOKIE,
STATE_COOKIE,
@@ -53,13 +54,7 @@ export const GET: RequestHandler = async ({ url, cookies }) => {
expiresAt: Math.floor(Date.now() / 1000) + (tokens.expires_in ?? 3600)
};
cookies.set(SESSION_COOKIE, await encodeSession(session), {
httpOnly: true,
sameSite: 'lax',
secure: url.protocol === 'https:',
path: '/',
maxAge: 60 * 60 * 24 * 7
});
cookies.set(SESSION_COOKIE, await encodeSession(session), sessionCookieOptions(url));
for (const name of [STATE_COOKIE, VERIFIER_COOKIE, NONCE_COOKIE, RETURN_COOKIE]) {
cookies.delete(name, { path: '/' });