fix: stop Secure session cookies from breaking login on plain-HTTP deployments - #214
Merged
Merged
Conversation
…ployments config/session.php previously defaulted the 'secure' session cookie flag to true whenever APP_ENV=production, regardless of whether the app was actually served over HTTPS. The shipped docker-compose.yml stack and the quick-start docker run example in DEPLOYMENT.md both set APP_ENV=production but never terminate TLS, so browsers silently dropped the Secure-flagged session cookie and login appeared to just do nothing, with no error surfaced anywhere. Default 'secure' based on whether APP_URL is served over https:// instead, since that reflects the actual public-facing transport rather than the deployment environment name. SESSION_SECURE_COOKIE remains an explicit override for anyone who needs to force the behavior either way. Also documents the new default near the affected DEPLOYMENT.md example so operators know to set APP_URL=https://... once TLS is terminated in front of the app. Fixes #120
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.
What was broken
config/session.phpdefaulted thesecuresession-cookie flag totruewheneverAPP_ENV=production, regardless of whether the app was actually reachable over HTTPS. The repo's own shipped "production" paths never terminate TLS:docker-compose.yml'sapp/queue/schedulerservices setAPP_ENV=production, but thenginxservice only listens on port 80 — no TLS anywhere in the stack.DEPLOYMENT.md's quick-startdocker run --target production -p 80:9000 -e APP_ENV=production ...example exposes the app directly over plain HTTP.Browsers silently discard
Secure-flagged cookies sent over plain HTTP. So anyone following either of those documented paths would get a session cookie that never survives a request — login just appeared to do nothing, with no error surfaced anywhere. This was a functional regression introduced whensecurewas given a production-based default (previously it had no default at all, so this exact path worked).What changed
config/session.php:securenow defaults based on whetherAPP_URLis served overhttps://, instead of onAPP_ENV. This reflects the actual public-facing transport rather than the deployment environment's name, so it self-corrects for every current and future deployment recipe without needing per-example patches.SESSION_SECURE_COOKIEstill works as an explicit override in either direction.DEPLOYMENT.md: added a short note next to the affected quick-start example explaining the new default and telling operators to setAPP_URL=https://your-domain.comonce TLS is actually terminated in front of the app.tests/Unit/SessionSecureCookieConfigTest.php: updated/extended to cover the newAPP_URL-based default, including a direct regression test for theAPP_ENV=production+ plain-HTTPAPP_URLcombination described above, a behind-TLS production case, and the explicit-override case.Verification
vendor/bin/pint --dirty— clean, no changes needed.composer test(full suite) — 208 passed, 7 skipped (pre-existing, unrelated skips), 0 failed.Fixes #120