Last modified: 2014-10-28 17:50:27 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T74186, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 72186 - Varnish: Mobile site redirect interferes with OAuth authorization process
Varnish: Mobile site redirect interferes with OAuth authorization process
Status: PATCH_TO_REVIEW
Product: Wikimedia
Classification: Unclassified
General/Unknown (Other open bugs)
wmf-deployment
Smartphone other
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
: ops
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-10-17 15:23 UTC by Vera de Kok
Modified: 2014-10-28 17:50 UTC (History)
7 users (show)

See Also:
Web browser: Other
Mobile Platform: Android
Assignee Huggle Beta Tester: ---


Attachments

Description Vera de Kok 2014-10-17 15:23:58 UTC
Hi, 

I have to always authorize the Flickr2Commons tool before using it. I also use this tool on my smartphone. When I've set the user agent of the browser I use (Habit Browser) to be Android, I get redirected to a blanc page after clicking on "allow". This is not the case when I set the browsers user agent to PC.
Comment 1 Vera de Kok 2014-10-17 15:28:12 UTC
Correction: the blank page says "Error retrieving token: mwoauthdatastore-request-token-not-found"
Comment 2 Andre Klapper 2014-10-17 15:46:56 UTC
What is the exact user agent string on the phone? Do you literally refer to the string "PC"? Exact strings welcome in order to reproduce...
Comment 3 Vera de Kok 2014-10-17 15:49:52 UTC
The user agent resulting in the error, eg. "Android":

Mozilla/5.0 (Linux; U; Android 4.0.1; ja-jp; Galaxy Nexus Build/ITL41D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30

The "PC" user agent not resulting in error: 
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; ja-jp) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16
Comment 4 Bawolff (Brian Wolff) 2014-10-17 16:08:51 UTC
Verified, when editing from a user-agent that would be redirected to the mobile site, after authorizing, page gets redirected to mobile site and errors.

E006

-----

Steps to reproduce:
*From a cell phone, where you have not opted out of mobile interface and it sends a mobile UA
*Go to http://tools.wmflabs.org/oauth-hello-world/index.php?action=authorize
*Follow instructions, eventually get an error.
Comment 5 Brad Jorsch 2014-10-17 16:42:35 UTC
(In reply to Bawolff (Brian Wolff) from comment #4)
> Verified, when editing from a user-agent that would be redirected to the
> mobile site, after authorizing, page gets redirected to mobile site and
> errors.

I had suspected this, thanks for confirming.

After some further investigation, it looks to me like it's actually a bug in WMF's varnish layer trying to redirect mobile clients to the mobile site: it doesn't hit on the first request that uses /w/index.php?title=Special:OAuth/authorize&oauth_token=abc123&oauth_consumer_key=abc123, but the POST back to /wiki/Special:OAuth/authorize is caught and since browsers treat a 302 redirect as 303 rather than 307 this breaks everything. The relevant code appears to be in the operations/puppet repo, templates/varnish/text-frontend.inc.vcl.erb, sub mobile_redirect.
Comment 6 Gerrit Notification Bot 2014-10-19 18:48:48 UTC
Change 167453 had a related patch set uploaded by MaxSem:
Perform mobile redirect only for GET requests

https://gerrit.wikimedia.org/r/167453
Comment 7 Chris Steipp 2014-10-21 23:19:33 UTC
(In reply to Brad Jorsch from comment #5)
> (In reply to Bawolff (Brian Wolff) from comment #4)
> > Verified, when editing from a user-agent that would be redirected to the
> > mobile site, after authorizing, page gets redirected to mobile site and
> > errors.
> 
> I had suspected this, thanks for confirming.
> 
> After some further investigation, it looks to me like it's actually a bug in
> WMF's varnish layer trying to redirect mobile clients to the mobile site: it
> doesn't hit on the first request that uses
> /w/index.php?title=Special:OAuth/
> authorize&oauth_token=abc123&oauth_consumer_key=abc123, but the POST back to
> /wiki/Special:OAuth/authorize is caught and since browsers treat a 302
> redirect as 303 rather than 307 this breaks everything. The relevant code
> appears to be in the operations/puppet repo,
> templates/varnish/text-frontend.inc.vcl.erb, sub mobile_redirect.

Yep, this is actually a known issue.

Mobile can't really redirect calls to /w/index.php, so OAuth app authors need to redirect their users to "/wiki/Special:OAuth/authorize?oauth_token=..." instead of "/w/index.php?title=...".

So Max'es patch will probably work, although then the login experience on mobile isn't great. And we'll have to make sure the centralauth handshake continues to work. Or OAuth app authors can use /wiki/Special:OAuth urls, and the experience is better, but we can't control their code. Or we make a special varnish rule to allow mobile redirecting for this specific url pattern ("/w/index.php?title=Special:OAuth/authorize")... But I haven't fully thought through what else that would impact.
Comment 8 Brad Jorsch 2014-10-21 23:34:28 UTC
I thought we had trouble with OAuth getting confused by internal rewriting somewhere that changed /wiki/Special:OAuth to /w/index.php?title=Special:OAuth and broke the signature validation. Did that get fixed?
Comment 9 Chris Steipp 2014-10-22 00:29:55 UTC
(In reply to Brad Jorsch from comment #8)
> I thought we had trouble with OAuth getting confused by internal rewriting
> somewhere that changed /wiki/Special:OAuth to
> /w/index.php?title=Special:OAuth and broke the signature validation. Did
> that get fixed?

Yeah, that's one of the confusing parts. For any calls that are signed, that is the case, so title=Special:OAuth is the best format for the url. The /authorize call is the only one not signed, since it's just redirecting the user, so the clean url can be used.
Comment 10 Gerrit Notification Bot 2014-10-28 17:50:27 UTC
Change 167453 merged by Faidon Liambotis:
Perform mobile redirect only for GET and HEAD requests

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

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links