Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2889949
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
6 KB
Referenced Files
None
Subscribers
None
View Options
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
@@ -1,88 +1,89 @@
<?php
final class PhabricatorApplicationAuth extends PhabricatorApplication {
public function canUninstall() {
return false;
}
public function getBaseURI() {
return '/auth/';
}
public function getIconName() {
return 'authentication';
}
public function getHelpURI() {
// NOTE: Although reasonable help exists for this in "Configuring Accounts
// and Registration", specifying a help URI here means we get the menu
// item in all the login/link interfaces, which is confusing and not
// helpful.
// TODO: Special case this, or split the auth and auth administration
// applications?
return null;
}
public function buildMainMenuItems(
PhabricatorUser $user,
PhabricatorController $controller = null) {
$items = array();
if ($user->isLoggedIn()) {
$item = id(new PHUIListItemView())
->addClass('core-menu-item')
->setName(pht('Log Out'))
->setIcon('power')
->setWorkflow(true)
->setHref('/logout/')
->setSelected(($controller instanceof PhabricatorLogoutController));
$items[] = $item;
}
return $items;
}
public function getApplicationGroup() {
return self::GROUP_ADMIN;
}
public function getRoutes() {
return array(
'/auth/' => array(
'' => 'PhabricatorAuthListController',
'config/' => array(
'new/' => 'PhabricatorAuthNewController',
'new/(?P<className>[^/]+)/' => 'PhabricatorAuthEditController',
'edit/(?P<id>\d+)/' => 'PhabricatorAuthEditController',
'(?P<action>enable|disable)/(?P<id>\d+)/' =>
'PhabricatorAuthDisableController',
),
'login/(?P<pkey>[^/]+)/' => 'PhabricatorAuthLoginController',
'register/(?:(?P<akey>[^/]+)/)?' => 'PhabricatorAuthRegisterController',
'start/' => 'PhabricatorAuthStartController',
'validate/' => 'PhabricatorAuthValidateController',
'unlink/(?P<pkey>[^/]+)/' => 'PhabricatorAuthUnlinkController',
'link/(?P<pkey>[^/]+)/' => 'PhabricatorAuthLinkController',
'confirmlink/(?P<akey>[^/]+)/'
=> 'PhabricatorAuthConfirmLinkController',
),
- '/oauth/google/login/' => 'PhabricatorAuthOldOAuthRedirectController',
+ '/oauth/(?P<provider>\w+)/login/'
+ => 'PhabricatorAuthOldOAuthRedirectController',
'/login/' => array(
'' => 'PhabricatorAuthStartController',
'email/' => 'PhabricatorEmailLoginController',
'etoken/(?P<token>\w+)/' => 'PhabricatorEmailTokenController',
'refresh/' => 'PhabricatorRefreshCSRFController',
'mustverify/' => 'PhabricatorMustVerifyEmailController',
),
'/logout/' => 'PhabricatorLogoutController',
);
}
}
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
@@ -1,21 +1,38 @@
<?php
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
@@ -1,39 +1,44 @@
<?php
final class PhabricatorAuthProviderOAuthGitHub
extends PhabricatorAuthProviderOAuth {
public function getProviderName() {
return pht('GitHub');
}
public function getConfigurationHelp() {
$uri = PhabricatorEnv::getProductionURI('/');
$callback_uri = $this->getLoginURI();
return pht(
"To configure GitHub OAuth, create a new GitHub Application here:".
"\n\n".
"https://github.com/settings/applications/new".
"\n\n".
"You should use these settings in your application:".
"\n\n".
" - **URL:** Set this to your full domain with protocol. For this ".
" Phabricator install, the correct value is: `%s`\n".
" - **Callback URL**: Set this to: `%s`\n".
"\n\n".
"Once you've created an application, copy the **Client ID** and ".
"**Client Secret** into the fields above.",
$uri,
$callback_uri);
}
protected function newOAuthAdapter() {
return new PhutilAuthAdapterOAuthGitHub();
}
protected function getLoginIcon() {
return 'Github';
}
+ public function getLoginURI() {
+ // TODO: Clean this up. See PhabricatorAuthOldOAuthRedirectController.
+ return PhabricatorEnv::getURI('/oauth/github/login/');
+ }
+
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sun, Jan 19, 12:52 (3 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1124776
Default Alt Text
(6 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment