Page MenuHomePhabricator

Support redirects to private endpoints
Closed, ResolvedPublic

Description

Some REST endpoints are private to the WMF network. When we redirect (or link) between them, we need to base our links on the InternalServer setting, rather than the CanonicalServer setting. However, the same response from the same endpoint may in some cases contain both: references to private and public endpoints. Note also that responses may be cacheable, and shouldn't vary on which protocol was used to send the request.

This indicates that the code that constructs the target URL will need to know whether the target is public or private. The Router class should get an getPrivateRouteUrl() method, in addition to getRouteUrl().

This bug was caught when we ran roundtrip testing and all tests started to fail. But, the issue can be illustrated with this:

ssastry@scandium:~$ curl -x scandium.eqiad.wmnet:80 'http://en.wikipedia.org/w/rest.php/en.wikipedia.org/v3/page/html/Hospet'
<!doctype html><title>Redirect</title><a href="https://en.wikipedia.org/w/rest.php/en.wikipedia.org/v3/page/html/Hospet/1087106448">https://en.wikipedia.org/w/rest.php/en.wikipedia.org/v3/page/html/Hospet/1087106448</a>

That request above uses scandium (which got the unreleased to-be-tested Parsoid code) as the proxy and you see that the http:// request gets redirected to a https:// url which now fails.

ssastry@scandium:~$ curl -x wtp1025.eqiad.wmnet:80 'http://en.wikipedia.org/w/rest.php/en.wikipedia.org/v3/page/html/Hospet'
<!doctype html><title>Redirect</title><a href="http://en.wikipedia.org/w/rest.php/en.wikipedia.org/v3/page/html/Hospet/1087106448">http://en.wikipedia.org/w/rest.php/en.wikipedia.org/v3/page/html/Hospet/1087106448</a>

That request above is to wtp1025 (production cluster running released code from last train) which redirected the http:// req. to a http:// url

Event Timeline

daniel triaged this task as High priority.Jul 1 2022, 4:39 PM
daniel created this task.

Change 810385 had a related patch set uploaded (by Daniel Kinzler; author: Daniel Kinzler):

[mediawiki/core@master] ParsoidHandler: fix redirect target URLs.

https://gerrit.wikimedia.org/r/810385

Change 810917 had a related patch set uploaded (by Daniel Kinzler; author: Daniel Kinzler):

[mediawiki/core@master] REST: introduce getPrivateRouteUrl

https://gerrit.wikimedia.org/r/810917

Change 810920 had a related patch set uploaded (by Daniel Kinzler; author: Daniel Kinzler):

[mediawiki/core@master] ParsoidHandler: optionally use private URLs for redirects

https://gerrit.wikimedia.org/r/810920

Change 810385 merged by jenkins-bot:

[mediawiki/core@master] ParsoidHandler: fix redirect target URLs.

https://gerrit.wikimedia.org/r/810385

Change 813896 had a related patch set uploaded (by Daniel Kinzler; author: Daniel Kinzler):

[mediawiki/services/parsoid@master] Implement relative redirects in parsoid extension.

https://gerrit.wikimedia.org/r/813896

Change 810917 merged by jenkins-bot:

[mediawiki/core@master] REST: introduce getPrivateRouteUrl

https://gerrit.wikimedia.org/r/810917

Change 813896 merged by jenkins-bot:

[mediawiki/services/parsoid@master] Implement relative redirects in parsoid extension.

https://gerrit.wikimedia.org/r/813896

Change 814892 had a related patch set uploaded (by Arlolra; author: Arlolra):

[mediawiki/vendor@master] Bump parsoid to 0.16.0-a16

https://gerrit.wikimedia.org/r/814892

Change 814892 merged by jenkins-bot:

[mediawiki/vendor@master] Bump parsoid to 0.16.0-a16

https://gerrit.wikimedia.org/r/814892

Change 810920 merged by jenkins-bot:

[mediawiki/core@master] ParsoidHandler: optionally use private URLs for redirects

https://gerrit.wikimedia.org/r/810920

daniel claimed this task.

Change 971242 had a related patch set uploaded (by Daniel Kinzler; author: Daniel Kinzler):

[mediawiki/services/parsoid@master] Emit relative redirects

https://gerrit.wikimedia.org/r/971242

Change 971242 merged by jenkins-bot:

[mediawiki/services/parsoid@master] Emit relative redirects.

https://gerrit.wikimedia.org/r/971242

Change 972001 had a related patch set uploaded (by Subramanya Sastry; author: Subramanya Sastry):

[mediawiki/vendor@master] Bump wikimedia/parsoid to 0.19.0-a5

https://gerrit.wikimedia.org/r/972001

Change 972001 merged by jenkins-bot:

[mediawiki/vendor@master] Bump wikimedia/parsoid to 0.19.0-a5

https://gerrit.wikimedia.org/r/972001