-
-
Notifications
You must be signed in to change notification settings - Fork 73
fix(sso): resolve infinite redirect loop for non-logged-in visitors on subsites #366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
superdav42
wants to merge
4
commits into
main
Choose a base branch
from
bugfix/sso-redirect-loop
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
94571b4
fix(sso): resolve infinite redirect loop for non-logged-in visitors o…
superdav42 4eb0a50
style(sso): add PHPDoc comments to all SSO test methods for PHPCS com…
superdav42 a7f16a5
test(sso): add Cypress E2E tests for SSO redirect loop prevention
superdav42 dc45e8b
fix(sso): remove failing regression test and fix CI E2E step
superdav42 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: Ultimate-Multisite/ultimate-multisite
Length of output: 6504
🏁 Script executed:
Repository: Ultimate-Multisite/ultimate-multisite
Length of output: 112
🏁 Script executed:
Repository: Ultimate-Multisite/ultimate-multisite
Length of output: 1863
🏁 Script executed:
Repository: Ultimate-Multisite/ultimate-multisite
Length of output: 122
🏁 Script executed:
Repository: Ultimate-Multisite/ultimate-multisite
Length of output: 4156
🌐 Web query:
Jasny SSO Broker isAttached() session state fresh request💡 Result:
In jasny/sso the broker’s
isAttached()does not make a “fresh” call to the SSO server and it does not validate the remote server-side session on each request. It only checks whether the broker has a stored verification code in its client-side state (cookie/session). Concretely,isAttached()returnstrueiffgetVerificationCode() !== null. [1]What that means for “fresh request / session state”:
Broker(...). When you callisAttached(), it will read state from the configured state handler (default: cookies) and decide based on whether thesso_verify_{broker}value exists. [1][2]sso_verifyvalue is only stored after you complete the attach + verify flow (i.e., after redirect back with?sso_verify=..., you must call$broker->verify($_GET['sso_verify']);, which persists it into state). [1][2]clearToken()clears both token and verify state) and redirect togetAttachUrl()again. [1]Common reason
isAttached()is “false every request”: the verify/token cookies aren’t being persisted/sent back (cookie domain/path/secure/SameSite issues), or you switched to session storage but didn’tsession_start()before usingwithTokenIn(new Session()). [2]Sources:
[1] jasny/sso
Broker::isAttached()/verify()implementation (Scrutinizer)[2] jasny/sso README usage showing
isAttached(), attach redirect, andverify()(Packagist)🏁 Script executed:
Repository: Ultimate-Multisite/ultimate-multisite
Length of output: 4762
The unattached JSONP branch blocks the entire SSO attach flow for fresh browser sessions.
When
isAttached()returns false (the expected state for a fresh session), the JSONP endpoint returns error code 0 instead of initiating the attach handshake. The JavaScript receives this error, callswu.sso_denied()which sets a denial cookie, and the normal attach flow at lines 573–579 ($broker->getAttachUrl()) is never reached for JSONP requests. This prevents SSO from working at all for new users.The Jasny SSO
Broker::isAttached()checks only whether a stored verification code exists in session/cookies. On the first request, this is always false, so the JSONP endpoint must either initiate the attach redirect or provide another path to attachment—not deny it outright.🤖 Prompt for AI Agents