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:
Hermes Backend 2026-11-13 21:15:05 -05:00
commit 72757e7c51
4 changed files with 67 additions and 4 deletions

View file

@ -79,6 +79,11 @@ VESSELAPI_IN_INGEST=0
ADMIN_USER=
ADMIN_PASSWORD_HASH=
ADMIN_SESSION_SECRET=
# Optional: force the session cookie's Secure flag (1/true/yes) when the app is
# reached over plain HTTP behind a TLS-terminating proxy that rewrites
# X-Forwarded-Proto to http (the cluster: Cloudflare tunnel -> Cilium Gateway).
# Leave unset locally so the cookie works over http://localhost.
ADMIN_COOKIE_SECURE=
# ── News pipeline (scraper + summarizer, profile `ingest`) ────────────────
# Scraper crawls urls.txt continuously (default 10s between crawls).