mirror of
https://github.com/cozystack/cozystack.git
synced 2026-12-05 14:42:05 +09:00
fix(dashboard): keep re-login working across tabs after logout
With OIDC enabled, signing out of the dashboard and signing back in often ends on the oauth2-proxy 403 page even though Keycloak accepted the password. The gatekeeper log shows Invalid authentication via OAuth2: CSRF token mismatch, potential attack oauth2-proxy keeps the state of a pending login in a single kc-access_csrf cookie. After a logout every other open console tab gets a 401 on its next API call or watch reconnect and starts its own sign-in, which overwrites that cookie, so the callback of the tab the user is typing into no longer matches. Giving each flow its own CSRF cookie keeps concurrent sign-ins independent; the limit caps how many abandoned flows can accumulate in the request headers. Tested by running the chart-rendered oauth2-proxy v7.12.0 config against a live Keycloak with two tabs signing in after a logout: without the flags the first tab gets the 403 above, with them both sign-ins complete. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
This commit is contained in:
1 parent
ce04ec3fb8
commit
4ad4a44014
2 files changed
+22
No files matched your search
@@ -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
|
||||
|
||||
@@ -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
|
||||
Reference in new issue
Block a user