fix: redirect to original resource URL after SSO login with expired session #3411
Open
Adityakk9031 wants to merge 1 commit into
Open
fix: redirect to original resource URL after SSO login with expired session #3411Adityakk9031 wants to merge 1 commit into
Adityakk9031 wants to merge 1 commit into
Conversation
Adityakk9031
requested review from
miloschwartz and
oschwartz10612
as code owners
July 8, 2026 18:38
Contributor
|
Was this accidently flipped? 3365 mentions when your session expires it'll not direct you back to the resource, a bit confused on the changes and testing parts. Cheers. |
Contributor
Author
|
Oh whoops, good catch! I got my commit messages mixed up when pushing this branch. The PR title, description, and the actual code files are correct for #3365 (redirecting back to the resource). I'll fix the commit message on merge. Sorry about that! |
Contributor
Author
|
@miloschwartz have a look please |
Contributor
Author
|
@oschwartz10612 have a look |
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.
Summary
Fixes #3365
When a user's session expired and they attempted to access a deep link of an SSO-protected resource, they were incorrectly redirected to the dashboard/panel after logging back in instead of their original destination URL.
Root Cause
Two separate issues caused the redirect context to be lost:
router.refresh()does not follow server redirects: InResourceAuthPortal.tsx, after successfully authenticating via SSO, the client calledrouter.refresh(). In Next.js App Router, this performs a client-side component re-fetch but does not trigger full-page browser navigation or follow server-sideredirect()calls returned during re-rendering. This left the user stuck on the auth portal page, eventually defaulting to the dashboard panel.postAuthPathoverriding target URL: Insrc/app/auth/resource/[resourceGuid]/page.tsx, if a resource had a custompostAuthPathconfigured, it unconditionally overrode thesearchParams.redirecttarget URL, always redirecting users to the default post-auth path rather than their requested deep link.Changes
1.
src/components/ResourceAuthPortal.tsxrouter.refresh()withwindow.location.reload(). This forces a full browser reload, maintaining the query parameters (including?redirect=...). The server then processes the request, performs the SSO token exchange, and successfully issues a 302 redirect that the browser follows to the deep link.console.log.2.
src/app/auth/resource/[resourceGuid]/page.tsxpostAuthPathif there is no?redirect=parameter present in the request. The user's requested deep link now has priority, and thepostAuthPathacts as a fallback.Testing
https://app.company.org/some/deep/path.https://app.company.org/some/deep/pathand not the main Pangolin panel.