feat(auth): ADMIN_COOKIE_SECURE forces the session cookie Secure
Behind the cluster's HTTP origin listener Envoy normalizes X-Forwarded-Proto to http, so _is_https() never fires and the session cookie was issued without Secure. Add an explicit deploy-time flag: set_session_cookie() now marks the cookie Secure when the env var is 1/true/yes (case-insensitive, stripped) or the header inference says https. clear_session_cookie() is unchanged, SameSite stays Lax. Tests cover flag-over-http, header-without-flag, and the local-dev path; docs/auth.md and .env.example document the variable.
This commit is contained in:
parent
d8113b37b8
commit
72757e7c51
4 changed files with 67 additions and 4 deletions
|
|
@ -60,6 +60,13 @@ arrived over https (`X-Forwarded-Proto`, i.e. behind Cloudflare). Signature and
|
|||
expiry are checked with `hmac.compare_digest`; a token for another username, or
|
||||
one signed with a different secret, is rejected.
|
||||
|
||||
Set `ADMIN_COOKIE_SECURE=1` (`true`/`yes` also work) whenever the deployment is
|
||||
TLS-only but the app itself is reached over plain HTTP. In the cluster the
|
||||
Cloudflare tunnel originates at the Cilium Gateway on plain HTTP and Envoy
|
||||
normalizes `X-Forwarded-Proto` to `http`, so the header inference never fires
|
||||
there — the flag is what makes the cookie `Secure` in the cluster. Leave it
|
||||
unset for local development, where the cookie has to work over `http://localhost`.
|
||||
|
||||
## Abuse controls
|
||||
|
||||
* **Login rate limit:** 5 failed attempts per client IP (first hop of
|
||||
|
|
|
|||
Loading…
Reference in a new issue