fix: restore /setup access after manager login - #1
Merged
Conversation
URL-encode the post-login redirect target so proxies and browsers parse next=/setup correctly, preserve next across failed login attempts, skip the login page when a valid session already exists, add Secure cookies behind HTTPS proxies, normalize /setup/ paths, and redirect unauthenticated setup form posts back to login instead of returning opaque 401 JSON. Co-authored-by: wra-sol <wra-sol@users.noreply.github.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.
Problem
After the manager session auth gate was added,
/setup(the reconfigure wizard) requires logging in at/manage/loginfirst. Several edge cases prevented reliable access:nextredirect parameter was not URL-encoded (?next=/setup), which some proxies/browsers parse incorrectlynext=/setuptarget, sending users to/manageinstead/manage/loginsaw the login form again instead of being forwardedSecureflag behind Railway's HTTPS proxy (X-Forwarded-Proto: https)POST /setupreturned raw401JSON instead of redirecting to login/setup/(trailing slash) did not match the setup route and fell through to the proxyFix
nextin all login redirect URLs (next=%2Fsetup)nextfrom the POST body when re-rendering the login form after a wrong password/manage/loginto their intended destinationSecureto session cookies whenX-Forwarded-Protoishttps/setup/→/setup)POST /setupto the login pageTests
Added 6 integration tests covering encoded redirects, login→setup flow, wrong-password
nextpreservation, authenticated login skip, unauth POST redirect, and trailing-slash handling. All 86 tests pass.How to verify after deploy
/setupon a configured server → should redirect to/manage/login?next=%2Fsetup/manage, click Reconfigure →/setupshould load without another login prompt (while session is valid)