From 527a0952a3f2e491a31f617672ee82466c54c706 Mon Sep 17 00:00:00 2001 From: Kasinhou <129340513+Kasinhou@users.noreply.github.com> Date: Wed, 28 Oct 2026 14:55:45 +0100 Subject: [PATCH] fix(security): harden dsAuthInfo auth cookie with Secure and SameSite (#1663) * Harden dsAuthInfo auth cookie with Secure and SameSite attributes Set secure and sameSite='lax' on the auth JWT cookie written in storeToken(), as defense-in-depth. The Secure flag is derived from the actual page protocol (location.protocol === 'https:') so it is applied on any https page, including behind a TLS-terminating reverse proxy, while local http dev still works. 'lax' is used rather than 'strict' so the cookie is still sent on the top-level navigation that returns from external authentication. * docs: shorten auth cookie security comment --------- Co-authored-by: Matus Kasak (cherry picked from commit 9bcd483826745abc5662e50b4c5b93b9edaa7482) --- src/app/core/auth/auth.service.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/app/core/auth/auth.service.ts b/src/app/core/auth/auth.service.ts index 4a155920865..61c6900b31f 100644 --- a/src/app/core/auth/auth.service.ts +++ b/src/app/core/auth/auth.service.ts @@ -492,7 +492,12 @@ export class AuthService { // Set the cookie expire date const expires = new Date(expireDate); - const options: Cookies.CookieAttributes = { expires: expires }; + // Use Secure on HTTPS; Lax allows external-auth redirects via top-level GET navigation. + const options: Cookies.CookieAttributes = { + expires: expires, + secure: this._window.nativeWindow.location?.protocol === 'https:', + sameSite: 'lax', + }; // Save cookie with the token return this.storage.set(TOKENITEM, token, options);