chore(web): harden post-auth redirects and legacy URL rewrite#1161
Merged
brendan-kellam merged 2 commits intomainfrom Apr 30, 2026
Merged
chore(web): harden post-auth redirects and legacy URL rewrite#1161brendan-kellam merged 2 commits intomainfrom
brendan-kellam merged 2 commits intomainfrom
Conversation
- Add explicit `redirect` callback to the NextAuth config that pins post-auth redirects to the same origin. This mirrors the documented Auth.js default but makes the protection visible in code rather than relying on upstream defaults. - Switch the legacy `/~/...` rewrite in `proxy.ts` from 308 to 301. The rewrite is a backwards-compat shim for v3.0.0–v4.16.8 page URLs, which are virtually all GETs; 301 has matching cache/permanence semantics but downgrades any stray POST to GET and drops the body. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This comment has been minimized.
This comment has been minimized.
Contributor
WalkthroughThe pull request updates the authentication redirect behavior and HTTP status codes in the proxy layer. NextAuth's post-authentication redirects are now constrained to same-origin targets through a new redirect callback, and the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Co-Authored-By: Claude Opus 4.7 (1M context) <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 SOU-945
Summary
redirectcallback to the NextAuth config inpackages/web/src/auth.ts. It restricts post-auth redirects (sign-in / sign-out,callbackUrl,redirectTo) to the same origin as the application. This mirrors the documented Auth.js default (reference), but makes the protection visible in code rather than relying on upstream defaults staying stable across major versions./~/...rewrite inpackages/web/src/proxy.tsfrom 308 to 301. The rewrite is a backwards-compat shim for v3.0.0–v4.16.8 page URLs, which are virtually all GETs. 301 has matching cache/permanence semantics but downgrades any stray POST to GET and drops the body, which is the right behavior for a path-rewrite shim.🤖 Generated with Claude Code
Summary by CodeRabbit