diff --git a/packages/system/linstor-gui/templates/gatekeeper.yaml b/packages/system/linstor-gui/templates/gatekeeper.yaml index 9f2c75732..aa34f8174 100644 --- a/packages/system/linstor-gui/templates/gatekeeper.yaml +++ b/packages/system/linstor-gui/templates/gatekeeper.yaml @@ -90,6 +90,15 @@ spec: - --cookie-name=kc-access - --cookie-secure=true - --cookie-secret=$(OAUTH2_PROXY_COOKIE_SECRET) + # One CSRF cookie per sign-in, kept for an hour: with a shared one, + # tabs signing in at once overwrite each other's state, and the + # default 15m fails a login page Keycloak still accepts for 30m. + # The limit keeps abandoned flows out of the headers; it cannot + # prune cookies older than the 168h --cookie-expire, so the + # lifetime stays finite and below that. + - --cookie-csrf-per-request=true + - --cookie-csrf-per-request-limit=10 + - --cookie-csrf-expire=1h - --skip-provider-button # No offline_access: that scope makes Keycloak issue an *offline* # refresh token, which is decoupled from the SSO session and is NOT diff --git a/packages/system/linstor-gui/tests/ingress_auth_test.yaml b/packages/system/linstor-gui/tests/ingress_auth_test.yaml index 1e2c9b80a..80bd53997 100644 --- a/packages/system/linstor-gui/tests/ingress_auth_test.yaml +++ b/packages/system/linstor-gui/tests/ingress_auth_test.yaml @@ -366,3 +366,28 @@ tests: - contains: path: spec.template.spec.containers[0].args content: --whitelist-domain=auth.example.org + + # One CSRF cookie per sign-in flow, kept for an hour: a shared cookie fails the + # callback of every tab but the last one to start a sign-in ("CSRF token + # mismatch"), the default 15m fails a login page Keycloak still accepts, and a + # lifetime past the 168h signature lifetime leaves cookies nothing can prune. + - it: keeps an hour-long CSRF cookie per sign-in flow + template: templates/gatekeeper.yaml + set: + _cluster: + root-host: example.org + oidc-enabled: "true" + expose-services: "linstor-gui" + asserts: + - contains: + path: spec.template.spec.containers[0].args + content: --cookie-csrf-per-request=true + - contains: + path: spec.template.spec.containers[0].args + content: --cookie-csrf-per-request-limit=10 + - contains: + path: spec.template.spec.containers[0].args + content: --cookie-csrf-expire=1h + - notContains: + path: spec.template.spec.containers[0].args + content: --cookie-csrf-expire=0