1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-29 02:02:41 +01:00

Make old GitHub OAuth URIs work for now

Summary: Ref T1536. Like Google, GitHub is actually strict about callback URIs too. Keep them pointed at the old URIs until we can gradually migrate.

Test Plan: Logged in with GitHub.

Reviewers: garoevans, davidreuss, btrahan

Reviewed By: garoevans

CC: aran

Maniphest Tasks: T1536

Differential Revision: https://secure.phabricator.com/D6265
This commit is contained in:
epriestley 2013-06-21 06:11:57 -07:00
parent 46f0d3aa81
commit 0a044ef275
3 changed files with 27 additions and 4 deletions

View file

@ -71,7 +71,8 @@ final class PhabricatorApplicationAuth extends PhabricatorApplication {
=> 'PhabricatorAuthConfirmLinkController',
),
'/oauth/google/login/' => 'PhabricatorAuthOldOAuthRedirectController',
'/oauth/(?P<provider>\w+)/login/'
=> 'PhabricatorAuthOldOAuthRedirectController',
'/login/' => array(
'' => 'PhabricatorAuthStartController',

View file

@ -3,18 +3,35 @@
final class PhabricatorAuthOldOAuthRedirectController
extends PhabricatorAuthController {
private $provider;
public function shouldRequireLogin() {
return false;
}
public function willProcessRequest(array $data) {
$this->provider = $data['provider'];
}
public function processRequest() {
// TODO: Most OAuth providers are OK with changing the redirect URI, but
// Google is strict. We need to respect the old OAuth URI until we can
// get installs to migrate. This just keeps the old OAuth URI working
// Google and GitHub are strict. We need to respect the old OAuth URI until
// we can get installs to migrate. This just keeps the old OAuth URI working
// by redirecting to the new one.
$provider_map = array(
'google' => 'google:google.com',
'github' => 'github:github.com',
);
if (!isset($provider_map[$this->provider])) {
return new Aphront404Response();
}
$provider_key = $provider_map[$this->provider];
$uri = $this->getRequest()->getRequestURI();
$uri->setPath($this->getApplicationURI('login/google:google.com/'));
$uri->setPath($this->getApplicationURI('login/'.$provider_key.'/'));
return id(new AphrontRedirectResponse())->setURI($uri);
}

View file

@ -36,4 +36,9 @@ final class PhabricatorAuthProviderOAuthGitHub
return 'Github';
}
public function getLoginURI() {
// TODO: Clean this up. See PhabricatorAuthOldOAuthRedirectController.
return PhabricatorEnv::getURI('/oauth/github/login/');
}
}