diff --git a/src/applications/auth/application/PhabricatorApplicationAuth.php b/src/applications/auth/application/PhabricatorApplicationAuth.php index 4b11931926..1858b95037 100644 --- a/src/applications/auth/application/PhabricatorApplicationAuth.php +++ b/src/applications/auth/application/PhabricatorApplicationAuth.php @@ -71,7 +71,8 @@ final class PhabricatorApplicationAuth extends PhabricatorApplication { => 'PhabricatorAuthConfirmLinkController', ), - '/oauth/google/login/' => 'PhabricatorAuthOldOAuthRedirectController', + '/oauth/(?P\w+)/login/' + => 'PhabricatorAuthOldOAuthRedirectController', '/login/' => array( '' => 'PhabricatorAuthStartController', diff --git a/src/applications/auth/controller/PhabricatorAuthOldOAuthRedirectController.php b/src/applications/auth/controller/PhabricatorAuthOldOAuthRedirectController.php index d2f985b663..84de83f7d2 100644 --- a/src/applications/auth/controller/PhabricatorAuthOldOAuthRedirectController.php +++ b/src/applications/auth/controller/PhabricatorAuthOldOAuthRedirectController.php @@ -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); } diff --git a/src/applications/auth/provider/PhabricatorAuthProviderOAuthGitHub.php b/src/applications/auth/provider/PhabricatorAuthProviderOAuthGitHub.php index c87628f7ec..fe57b7d96a 100644 --- a/src/applications/auth/provider/PhabricatorAuthProviderOAuthGitHub.php +++ b/src/applications/auth/provider/PhabricatorAuthProviderOAuthGitHub.php @@ -36,4 +36,9 @@ final class PhabricatorAuthProviderOAuthGitHub return 'Github'; } + public function getLoginURI() { + // TODO: Clean this up. See PhabricatorAuthOldOAuthRedirectController. + return PhabricatorEnv::getURI('/oauth/github/login/'); + } + }