Files
cozystack/packages/system/dashboard
Alexey Artamonov 777721f5f7 fix(dashboard): keep a slow re-login from failing on an expired CSRF cookie
After a logout the console lands straight on the Keycloak login page.
If that page stays open for more than 15 minutes before the password
is entered, the callback fails with a 403 and the gatekeeper logs

  unable to obtain CSRF cookie: ... CSRF cookie with name
  'kc-access_<state>_csrf' was not found

oauth2-proxy gives the CSRF cookie a fixed Max-Age of
--cookie-csrf-expire (15m by default), while Keycloak keeps a login
page usable for 30 minutes and then restarts the flow with the
original state, so the browser drops the cookie while the login it
belongs to is still alive.

The lifetime becomes 1h, which outlives Keycloak's login lifespan. It
stays finite and well below --cookie-expire (168h) on purpose: a CSRF
cookie with an older signature fails validation, and the per-request
limit skips such cookies instead of deleting them, so a cookie the
browser keeps longer than that would stay in the request headers.

Tested by running the chart-rendered oauth2-proxy v7.12.0 config
against a live Keycloak, waiting in real time: after a logout, a login
page left open for 16 minutes fails with the 403 above on the default
lifetime and signs in once the cookie outlives the wait; at 31 minutes
Keycloak asks for the password again and the login then completes.
The same binary sets Max-Age=3600 on the CSRF cookie with this flag.

Assisted-by: LLM
Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
2026-12-02 16:10:53 +03:00
..
2024-07-16 17:31:52 +02:00