diff --git a/packages/system/dashboard/templates/gatekeeper.yaml b/packages/system/dashboard/templates/gatekeeper.yaml index aa4a6b2a8..ecebdaf72 100644 --- a/packages/system/dashboard/templates/gatekeeper.yaml +++ b/packages/system/dashboard/templates/gatekeeper.yaml @@ -76,6 +76,12 @@ spec: # abandoned flows from piling up in the request headers. - --cookie-csrf-per-request=true - --cookie-csrf-per-request-limit=10 + # Keycloak accepts a login page for 30m and then restarts it with the + # original state, so the default 15m fails the callback of a login + # page left open longer. Keep it finite and below the 168h + # --cookie-expire: older CSRF cookies fail signature checks, and + # the per-request limit skips them instead of deleting them. + - --cookie-csrf-expire=1h - --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 ff2ad9d2d..d6ad496c3 100644 --- a/packages/system/dashboard/tests/gatekeeper_test.yaml +++ b/packages/system/dashboard/tests/gatekeeper_test.yaml @@ -221,3 +221,20 @@ tests: - contains: path: spec.template.spec.containers[0].args content: --cookie-csrf-per-request-limit=10 + + # The CSRF cookie has to outlive Keycloak's 30m login lifespan, or a login page + # left open that long fails its callback, and stay finite and below the 168h + # signature lifetime, past which oauth2-proxy can neither read nor prune it. + - it: keeps the CSRF cookie for an hour + 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-expire=1h + - notContains: + path: spec.template.spec.containers[0].args + content: --cookie-csrf-expire=0