The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
docs(auth): correct the SameSite contract in the cookie source docs
Ben Barclay91191123ed23
diff --git a/hermes_cli/dashboard_auth/base.py b/hermes_cli/dashboard_auth/base.pyindex e8b8a7730b1..2d744c6cf3d 100644--- a/hermes_cli/dashboard_auth/base.py+++ b/hermes_cli/dashboard_auth/base.py@@ -61,8 +61,16 @@ class LoginStart:Portal's ``/oauth/authorize``). ``cookie_payload`` is a dict of cookiename → serialised value that the auth route will ``Set-Cookie`` on theresponse. Used for PKCE state, CSRF nonces, etc. Cookies set here MUST- be HttpOnly + Secure (when over HTTPS) + SameSite=Lax with a TTL ≤ 10- minutes (the login lifetime).+ be HttpOnly + Secure (when over HTTPS) with a TTL ≤ 10 minutes (the+ login lifetime).++ SameSite: use ``Lax`` by default. The one exception is the PKCE state+ cookie, which is ``SameSite=None; Secure`` over HTTPS — it is set on+ the ``/auth/login`` 302 and has to survive the cross-site redirect+ chain back from the IDP, which Chromium drops intermittently under+ ``Lax`` (crbug 40508226). Over plain HTTP it stays ``Lax``, since+ ``SameSite=None`` requires ``Secure``. See+ :func:`hermes_cli.dashboard_auth.cookies.set_pkce_cookie`."""redirect_url: strdiff --git a/hermes_cli/dashboard_auth/cookies.py b/hermes_cli/dashboard_auth/cookies.pyindex 5d41bc31d23..ed6f89a8e8b 100644--- a/hermes_cli/dashboard_auth/cookies.py+++ b/hermes_cli/dashboard_auth/cookies.py@@ -17,14 +17,24 @@ Three cookies in play:- hermes_session_pkce: short-lived PKCE state + CSRF nonce + providerhint (HttpOnly, lifetime = 10 minutes)-All three are ``SameSite=Lax`` (browser will send on cross-site GET-top-level navigation, which we need for the IDP redirect back to-``/auth/callback``) and live under the prefix's Path. ``Secure`` is set-ONLY when the dashboard was reached over HTTPS — detected via the-request URL scheme, which honours ``X-Forwarded-Proto`` upstream of-Fly's TLS terminator when uvicorn is configured with-``proxy_headers=True``. Loopback dev traffic is always HTTP so-``Secure`` would lock the cookies out of the browser.+The two session cookies are ``SameSite=Lax`` and live under the prefix's+Path. The PKCE cookie is the exception: ``SameSite=None`` over HTTPS,+falling back to ``Lax`` on plain HTTP (where ``SameSite=None`` is invalid+without ``Secure``). It is set on the ``/auth/login`` 302 and must survive+the cross-site redirect chain out to the IDP and back to+``/auth/callback``; Chromium intermittently drops ``Lax`` cookies set on a+302 in such a chain (crbug 40508226), which surfaces as "Missing PKCE+state cookie". ``Secure`` is set ONLY when the dashboard was reached over+HTTPS — detected via the request URL scheme, which honours+``X-Forwarded-Proto`` upstream of Fly's TLS terminator when uvicorn is+configured with ``proxy_headers=True``. Loopback dev traffic is always+HTTP so ``Secure`` would lock the cookies out of the browser.++NOTE: uvicorn only honours ``X-Forwarded-Proto`` from a peer inside its+``forwarded_allow_ips`` (default: ``127.0.0.1``). A TLS terminator that+reaches the dashboard from a non-loopback address — e.g. a reverse proxy+in its own container — is not trusted, so the request still looks like+HTTP here and these cookies are written in their HTTP shape.Cookie prefix selection (browser hardening perhttps://datatracker.ietf.org/doc/html/draft-west-cookie-prefixes):