diff --git a/packages/system/dashboard/templates/gatekeeper.yaml b/packages/system/dashboard/templates/gatekeeper.yaml index 0f90dd039..aa4a6b2a8 100644 --- a/packages/system/dashboard/templates/gatekeeper.yaml +++ b/packages/system/dashboard/templates/gatekeeper.yaml @@ -70,6 +70,12 @@ spec: - --cookie-name=kc-access - --cookie-secure=true - --cookie-secret=$(OAUTH2_PROXY_COOKIE_SECRET) + # After a logout every open console tab starts its own sign-in; with + # a single shared CSRF cookie the newest flow overwrites the others + # and the callback of any other tab fails with a 403. The limit keeps + # abandoned flows from piling up in the request headers. + - --cookie-csrf-per-request=true + - --cookie-csrf-per-request-limit=10 - --skip-provider-button {{- if eq $oidcInsecureSkipVerify "true" }} - --ssl-insecure-skip-verify=true diff --git a/packages/system/dashboard/tests/gatekeeper_test.yaml b/packages/system/dashboard/tests/gatekeeper_test.yaml index 4ac7d5ab9..ff2ad9d2d 100644 --- a/packages/system/dashboard/tests/gatekeeper_test.yaml +++ b/packages/system/dashboard/tests/gatekeeper_test.yaml @@ -205,3 +205,19 @@ tests: - notContains: path: spec.template.spec.containers[0].args content: --whitelist-domain=keycloak.example.org + + # A shared CSRF cookie fails the re-login callback of every console tab but the + # last one to start a sign-in after a logout ("CSRF token mismatch", 403). + - it: keeps one CSRF cookie per sign-in flow + template: templates/gatekeeper.yaml + set: + _cluster: + root-host: example.org + oidc-enabled: "true" + 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