Skip to content

Commit 1834584

Browse files
author
epriestley
committed
Provide contextual help on auth provider configuration
Summary: Ref T1536. - Move all the provider-specific help into contextual help in Auth. - This provides help much more contextually, and we can just tell the user the right values to use to configure things. - Rewrite account/registration help to reflect the newer state of the word. - Also clean up a few other loose ends. Test Plan: {F46937} Reviewers: chad, btrahan Reviewed By: chad CC: aran Maniphest Tasks: T1536 Differential Revision: https://secure.phabricator.com/D6247
1 parent 3b9ccf1 commit 1834584

18 files changed

+167
-158
lines changed

conf/default.conf.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -553,11 +553,6 @@
553553

554554
// -- Auth ------------------------------------------------------------------ //
555555

556-
// Can users login with a username/password, or by following the link from
557-
// a password reset email? You can disable this and configure one or more
558-
// OAuth providers instead.
559-
'auth.password-auth-enabled' => true,
560-
561556
// Maximum number of simultaneous web sessions each user is permitted to have.
562557
// Setting this to "1" will prevent a user from logging in on more than one
563558
// browser at the same time.
@@ -1032,10 +1027,6 @@
10321027
'aphront.default-application-configuration-class' =>
10331028
'AphrontDefaultApplicationConfiguration',
10341029

1035-
'controller.oauth-registration' =>
1036-
'PhabricatorOAuthDefaultRegistrationController',
1037-
1038-
10391030
// Directory that phd (the Phabricator daemon control script) should use to
10401031
// track running daemons.
10411032
'phd.pid-directory' => '/var/tmp/phd/pid',

src/applications/auth/application/PhabricatorApplicationAuth.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ public function getIconName() {
1414
return 'authentication';
1515
}
1616

17+
public function getHelpURI() {
18+
// NOTE: Although reasonable help exists for this in "Configuring Accounts
19+
// and Registration", specifying a help URI here means we get the menu
20+
// item in all the login/link interfaces, which is confusing and not
21+
// helpful.
22+
23+
// TODO: Special case this, or split the auth and auth administration
24+
// applications?
25+
26+
return null;
27+
}
28+
1729
public function buildMainMenuItems(
1830
PhabricatorUser $user,
1931
PhabricatorController $controller = null) {

src/applications/auth/controller/PhabricatorEmailLoginController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public function shouldRequireLogin() {
1010
public function processRequest() {
1111
$request = $this->getRequest();
1212

13-
if (!PhabricatorEnv::getEnvConfig('auth.password-auth-enabled')) {
13+
if (!PhabricatorAuthProviderPassword::getPasswordProvider()) {
1414
return new Aphront400Response();
1515
}
1616

src/applications/auth/controller/PhabricatorEmailTokenController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function processRequest() {
7474
unset($unguarded);
7575

7676
$next = '/';
77-
if (!PhabricatorEnv::getEnvConfig('auth.password-auth-enabled')) {
77+
if (!PhabricatorAuthProviderPassword::getPasswordProvider()) {
7878
$next = '/settings/panel/external/';
7979
} else if (PhabricatorEnv::getEnvConfig('account.editable')) {
8080
$next = (string)id(new PhutilURI('/settings/panel/password/'))

src/applications/auth/controller/config/PhabricatorAuthEditController.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,12 @@ public function processRequest() {
224224
->addCancelButton($cancel_uri)
225225
->setValue($button));
226226

227+
$help = $provider->getConfigurationHelp();
228+
if ($help) {
229+
$form->appendChild(id(new PHUIFormDividerControl()));
230+
$form->appendRemarkupInstructions($help);
231+
}
232+
227233
$crumbs = $this->buildApplicationCrumbs();
228234
$crumbs->addCrumb(
229235
id(new PhabricatorCrumbView())

src/applications/auth/provider/PhabricatorAuthProvider.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ public function getProviderConfig() {
2121
return $this->providerConfig;
2222
}
2323

24+
public function getConfigurationHelp() {
25+
return null;
26+
}
27+
2428
public function getDefaultProviderConfig() {
2529
return id(new PhabricatorAuthProviderConfig())
2630
->setProviderClass(get_class($this))

src/applications/auth/provider/PhabricatorAuthProviderOAuthDisqus.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,24 @@ public function getProviderName() {
77
return pht('Disqus');
88
}
99

10+
public function getConfigurationHelp() {
11+
$login_uri = $this->getLoginURI();
12+
13+
return pht(
14+
"To configure Disqus OAuth, create a new application here:".
15+
"\n\n".
16+
"http://disqus.com/api/applications/".
17+
"\n\n".
18+
"Create an application, then adjust these settings:".
19+
"\n\n".
20+
" - **Callback URL:** Set this to `%s`".
21+
"\n\n".
22+
"After creating an application, copy the **Public Key** and ".
23+
"**Secret Key** to the fields above (the **Public Key** goes in ".
24+
"**OAuth App ID**).",
25+
$login_uri);
26+
}
27+
1028
protected function newOAuthAdapter() {
1129
return new PhutilAuthAdapterOAuthDisqus();
1230
}

src/applications/auth/provider/PhabricatorAuthProviderOAuthFacebook.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,25 @@ public function getProviderName() {
99
return pht('Facebook');
1010
}
1111

12+
public function getConfigurationHelp() {
13+
$uri = new PhutilURI(PhabricatorEnv::getProductionURI('/'));
14+
return pht(
15+
'To configure Facebook OAuth, create a new Facebook Application here:'.
16+
"\n\n".
17+
'https://developers.facebook.com/apps'.
18+
"\n\n".
19+
'You should use these settings in your application:'.
20+
"\n\n".
21+
" - **Site URL**: Set this to your full domain with protocol. For ".
22+
" this Phabricator install, the correct value is: `%s`\n".
23+
" - **Site Domain**: Set this to the full domain without a protocol. ".
24+
" For this Phabricator install, the correct value is: `%s`\n\n".
25+
"After creating your new application, copy the **App ID** and ".
26+
"**App Secret** to the fields above.",
27+
(string)$uri,
28+
$uri->getDomain());
29+
}
30+
1231
public function getDefaultProviderConfig() {
1332
return parent::getDefaultProviderConfig()
1433
->setProperty(self::KEY_REQUIRE_SECURE, 1);

src/applications/auth/provider/PhabricatorAuthProviderOAuthGitHub.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,27 @@ public function getProviderName() {
77
return pht('GitHub');
88
}
99

10+
public function getConfigurationHelp() {
11+
$uri = PhabricatorEnv::getProductionURI('/');
12+
$callback_uri = $this->getLoginURI();
13+
14+
return pht(
15+
"To configure GitHub OAuth, create a new GitHub Application here:".
16+
"\n\n".
17+
"https://github.com/settings/applications/new".
18+
"\n\n".
19+
"You should use these settings in your application:".
20+
"\n\n".
21+
" - **URL:** Set this to your full domain with protocol. For this ".
22+
" Phabricator install, the correct value is: `%s`\n".
23+
" - **Callback URL**: Set this to: `%s`\n".
24+
"\n\n".
25+
"Once you've created an application, copy the **Client ID** and ".
26+
"**Client Secret** into the fields above.",
27+
$uri,
28+
$callback_uri);
29+
}
30+
1031
protected function newOAuthAdapter() {
1132
return new PhutilAuthAdapterOAuthGitHub();
1233
}

src/applications/auth/provider/PhabricatorAuthProviderOAuthGoogle.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,27 @@ public function getProviderName() {
77
return pht('Google');
88
}
99

10+
public function getConfigurationHelp() {
11+
$login_uri = $this->getLoginURI();
12+
13+
return pht(
14+
"To configure Google OAuth, create a new 'API Project' here:".
15+
"\n\n".
16+
"https://code.google.com/apis/console/".
17+
"\n\n".
18+
"You don't need to enable any Services, just go to **API Access**, ".
19+
"click **Create an OAuth 2.0 client ID...**, and configure these ".
20+
"settings:".
21+
"\n\n".
22+
" - During initial setup click **More Options** (or after creating ".
23+
" the client ID, click **Edit Settings...**), then add this to ".
24+
" **Authorized Redirect URIs**: `%s`\n".
25+
"\n\n".
26+
"After completing configuration, copy the **Client ID** and ".
27+
"**Client Secret** to the fields above.",
28+
$login_uri);
29+
}
30+
1031
protected function newOAuthAdapter() {
1132
return new PhutilAuthAdapterOAuthGoogle();
1233
}

0 commit comments

Comments
 (0)