Login: Fix redirect_to handling for WordPress.com subdomains#109808
Open
lancewillett wants to merge 3 commits intotrunkfrom
Open
Login: Fix redirect_to handling for WordPress.com subdomains#109808lancewillett wants to merge 3 commits intotrunkfrom
lancewillett wants to merge 3 commits intotrunkfrom
Conversation
After logging in, users visiting P2 sites (*.wordpress.com subdomains) were redirected to / instead of their original URL. Two issues: 1. isExternalUrl() in redirect-logged-in only allowed exact hostname matches for wordpress.com, rejecting valid subdomains like testp2020a8c.wordpress.com. Now allows all *.wordpress.com subdomains. 2. rebootAfterLogin used only the API-sanitized redirect_to with a / fallback. If the API didn't echo redirect_to, the original URL parameter was lost. Now falls back to getRedirectToOriginal() before defaulting to /. See: P2HQ-55 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Jetpack Cloud Live (direct link)
Automattic for Agencies Live (direct link)
Dashboard Live (dotcom) (direct link)
|
Add tests covering the two fixes in the previous commit: - redirect-logged-in: *.wordpress.com subdomains are allowed, non-https subdomains are rejected - reboot-after-login: falls back to original redirect_to when sanitized is null, prefers sanitized when both are set See: P2HQ-55 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
|
This PR modifies the release build for the following Calypso Apps: For info about this notification, see here: PCYsg-OT6-p2
To test WordPress.com changes, run |
Co-Authored-By: Claude Opus 4.6 (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.
Proposed Changes
*.wordpress.comsubdomains in the login redirect URL allowlistredirect_toURL parameter when the API doesn't return oneWhy are these changes being made?
See P2HQ-55
When users visit a private P2 site while logged out, P2 correctly sets
redirect_toto the original URL. After logging in, two issues prevent the redirect from working:isExternalUrl()inredirect-logged-intreats*.wordpress.comsubdomains (e.g.,myteamp2.wordpress.com) as external URLs because the allowlist only matches exact hostnames. Theredirect_tois silently dropped.rebootAfterLoginrelies solely on the API-sanitizedredirect_to. If the API doesn't echo it back, the original URL parameter from the login page is ignored entirely, defaulting to/.Users end up at
wordpress.com/p2/instead of the P2 they were trying to visit.Testing Instructions
cAFMY-p2redirect_to=https%3A%2F%2Fmyteamp2.wordpress.com%2Fmyteamp2.wordpress.comwordpress.com/p2/Also test the "already logged in" path:
https://wordpress.com/log-in?redirect_to=https%3A%2F%2Fmyteamp2.wordpress.com%2Fmyteamp2.wordpress.comPre-merge Checklist