feat(auth): ADMIN_COOKIE_SECURE forces the session cookie Secure #51
Loading…
Reference in a new issue
No description provided.
Delete branch "wt/t_e5a0c384"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
Live at
https://osint.siriusdevops.comthe session cookie is issued withoutSecure:_is_https()trustsX-Forwarded-Proto, but that header never arrives ashttps: the Cloudflare tunnel originates at the Cilium Gateway on plain HTTP and Envoy normalizes the header tohttp(an explicit clientX-Forwarded-Proto: httpssent straight at10.10.0.2:8080is discarded too). ASecure-less cookie on an https-only site is sendable over a plaintext downgrade.What changed
app/auth.py—set_session_cookie()now setssecure=Truewhen_is_https(request)orADMIN_COOKIE_SECUREis truthy (1/true/yes, case-insensitive, whitespace-stripped). Header inference kept as the fallback;cookie_secure_forced()reads the env per call.clear_session_cookie()untouched (Secureon a delete would break clearing a cookie set over http in local dev).SameSite=Laxunchanged.docs/auth.md— paragraph in “Session cookie” explaining why the header inference is useless behind an HTTP origin listener and that the flag is what makes the cluster cookieSecure..env.example— documentsADMIN_COOKIE_SECUREnext to the other three admin vars.tests/test_auth.py— flag +X-Forwarded-Proto: http⇒Secure; unset +X-Forwarded-Proto: https⇒Secure; unset + no header ⇒ noSecure; truthy/falsey spellings parametrized.Verification
pytest -q -rs: 344 passed, 17 skipped — all 17 skips areintegration(test DB unreachable:DB_HOST/DB_PORTunset,tests/test_api_*.py,test_fire_ingest.py).tests/test_auth.pyalone: 54 passed.Manual,
uvicorn main:app --port 8099 --lifespan off(--lifespan offonly because the startup lifespan requires Postgres; the login route does not):Operator follow-up (not in this PR)
Set
ADMIN_COOKIE_SECURE=1in the cluster ConfigMap (apps/base/osint/insirius/homek8s), rebuild the amd64 image and bump the pin.probeto feat(auth): ADMIN_COOKIE_SECURE forces the session cookie Secure