Repository navigation
Mark the session cookie Secure behind a TLS-terminating proxy - #68
Merged
Merged
Conversation
COOKIE_SECURE=auto read X-Forwarded-Proto, which nginx overwrites with its own scheme: http when a proxy or tunnel terminates TLS and talks plain HTTP to port 3000. The cookie then lacked Secure on an HTTPS site. nginx now passes on what the proxy received as X-Proxy-Forwarded-Proto, believed only from TRUSTED_PROXIES. Fixes #56 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #56
Replaces #64, which GitHub closed when its base branch (#63's) was deleted on merge. Same change, now merged with
main(which has #63'sTRUSTED_PROXIES).What changed
default.conf: the/api/and/auth/locations (where cookies are set) also passX-Proxy-Forwarded-Proto: $http_x_forwarded_proto, i.e. what the proxy in front received.X-Forwarded-Protostays nginx's own$scheme._cookie_secure()(COOKIE_SECURE=auto) usesX-Proxy-Forwarded-Protoonly when the peer is inTRUSTED_PROXIES; otherwise unchanged.Testing
pytest(merged withmain): 270 passed, 8 skipped. New tests: direct HTTPS; a trusted tunnel terminating TLS → Secure; the same withoutTRUSTED_PROXIES→ not believed; a direct visitor claiming https → not believed; a trusted proxy that received http; a trusted proxy sending no scheme. The tunnel case fails without the fix.connecthub_sessioncookie should showSecurein dev tools when signed in through the tunnel.🤖 Generated with Claude Code