From 86e442fac9c34c58bd2e2580496b7a9461aec10b Mon Sep 17 00:00:00 2001 From: Andres Schumann Date: Tue, 24 Nov 2026 03:39:49 +0100 Subject: [PATCH] Default session cookie SameSite to Lax Strict stops the browser from sending the session cookie on the cross-site redirect that returns from external identity providers (SAML, OAuth2, Entra ID). Lax sends it on top-level navigations, which is what those callbacks need. Administrators can still select Strict in the security configuration. The default test is updated to match. --- src/uds/core/util/config.py | 2 +- tests/core/util/test_session_samesite.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/uds/core/util/config.py b/src/uds/core/util/config.py index e2cc9037b..838d44975 100644 --- a/src/uds/core/util/config.py +++ b/src/uds/core/util/config.py @@ -432,7 +432,7 @@ def get_config_values( SESSION_COOKIE_SAMESITE_VALUES: typing.Final[tuple[str, ...]] = ("Lax", "Strict") -SESSION_COOKIE_SAMESITE_DEFAULT: typing.Final[str] = "Strict" +SESSION_COOKIE_SAMESITE_DEFAULT: typing.Final[str] = "Lax" class GlobalConfig: diff --git a/tests/core/util/test_session_samesite.py b/tests/core/util/test_session_samesite.py index be3a0833f..8afc63ef9 100644 --- a/tests/core/util/test_session_samesite.py +++ b/tests/core/util/test_session_samesite.py @@ -63,15 +63,15 @@ def session_cookie_samesite(self) -> str: response = middleware.process_response(request, HttpResponse()) return str(response.cookies[settings.SESSION_COOKIE_NAME]["samesite"]) - def test_default_is_strict_when_not_saved(self) -> None: - self.assertEqual(SESSION_COOKIE_SAMESITE_DEFAULT, "Strict") + def test_default_is_lax_when_not_saved(self) -> None: + self.assertEqual(SESSION_COOKIE_SAMESITE_DEFAULT, "Lax") DBConfig.objects.filter( section=GlobalConfig.SESSION_COOKIE_SAMESITE.section(), key=GlobalConfig.SESSION_COOKIE_SAMESITE.key(), ).delete() - self.assertEqual(settings.SESSION_COOKIE_SAMESITE, "Strict") - self.assertEqual(self.session_cookie_samesite(), "Strict") + self.assertEqual(settings.SESSION_COOKIE_SAMESITE, "Lax") + self.assertEqual(self.session_cookie_samesite(), "Lax") def test_value_saved_from_web_is_applied_to_session_cookie(self) -> None: for value in ("Lax", "Strict"):