mirror of
https://github.com/cozystack/cozystack.git
synced 2026-12-05 14:42:05 +09:00
fix(linstor-gui): keep concurrent and slow sign-ins from failing on CSRF
The linstor-gui gatekeeper runs oauth2-proxy with the same single, 15-minute CSRF cookie the dashboard had. Once the session ends, for example after a logout from the dashboard, every linstor-gui tab that is reloaded starts its own sign-in and overwrites the cookie of the others, so finishing the login in any tab but the last one fails with a 403 and "CSRF token mismatch, potential attack"; a login page left open for more than 15 minutes fails the same way with "CSRF cookie ... was not found", although Keycloak still accepts it. Give each sign-in its own CSRF cookie, cap how many can pile up in the request headers, and keep them for 1h instead of 15 minutes, which outlives Keycloak's 30-minute login lifespan. The lifetime stays finite and well inside --cookie-expire (168h): an older CSRF cookie fails signature validation and the per-request limit skips it instead of deleting it, so a longer-lived cookie would accumulate. Tested by running oauth2-proxy v7.12.0 with the chart-rendered gatekeeper arguments against a live Keycloak: with two tabs signing in after the session ended, the current arguments fail the first tab with the CSRF mismatch and the new ones sign both in. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
This commit is contained in:
1 parent
06c2be9745
commit
cabbb8faf0
2 files changed
+34
No files matched your search
@@ -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
|
||||
|
||||
@@ -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
|
||||
Reference in new issue
Block a user