Skip to content

Commit 1834584

Browse files
author
epriestley
committedJun 20, 2013
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

-9
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

+12
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

+1-1
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

+1-1
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

+6
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

+4
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

+18
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

+19
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

+21
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

+21
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
}

‎src/applications/auth/provider/PhabricatorAuthProviderPassword.php

+18
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ public function getProviderName() {
99
return pht('Username/Password');
1010
}
1111

12+
public function getConfigurationHelp() {
13+
return pht(
14+
'You can select a minimum password length by setting '.
15+
'`account.minimum-password-length` in configuration.');
16+
}
17+
1218
public function getDescriptionForCreate() {
1319
return pht(
1420
'Allow users to login or register using a username and password.');
@@ -227,4 +233,16 @@ public function willRegisterAccount(PhabricatorExternalAccount $account) {
227233
$account->setAccountID($account->getUserPHID());
228234
}
229235

236+
public static function getPasswordProvider() {
237+
$providers = self::getAllEnabledProviders();
238+
239+
foreach ($providers as $provider) {
240+
if ($provider instanceof PhabricatorAuthProviderPassword) {
241+
return $provider;
242+
}
243+
}
244+
245+
return null;
246+
}
247+
230248
}

‎src/applications/base/controller/PhabricatorController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ final public function willBeginExecution() {
101101

102102
if ($this->shouldRequireLogin() && !$user->getPHID()) {
103103
$login_controller = new PhabricatorAuthStartController($request);
104-
$login_controller->setCurrentApplication(
104+
$this->setCurrentApplication(
105105
PhabricatorApplication::getByClass('PhabricatorApplicationAuth'));
106106
return $this->delegateToController($login_controller);
107107
}

‎src/applications/config/option/PhabricatorAuthenticationConfigOptions.php

-13
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,6 @@ public function getDescription() {
1313

1414
public function getOptions() {
1515
return array(
16-
$this->newOption(
17-
'auth.password-auth-enabled', 'bool', true)
18-
->setBoolOptions(
19-
array(
20-
pht("Allow password authentication"),
21-
pht("Don't allow password authentication")
22-
))
23-
->setSummary(pht("Enables password-based authentication."))
24-
->setDescription(
25-
pht(
26-
"Can users login with a username/password, or by following the ".
27-
"link from a password reset email? You can disable this and ".
28-
"configure one or more OAuth providers instead.")),
2916
$this->newOption('auth.sessions.web', 'int', 5)
3017
->setSummary(
3118
pht("Number of web sessions a user can have simultaneously."))

‎src/applications/config/option/PhabricatorExtendingPhabricatorConfigOptions.php

-6
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,6 @@ public function getOptions() {
4747
->setBaseClass('AphrontApplicationConfiguration')
4848
// TODO: This could probably use some better documentation.
4949
->setDescription(pht("Application configuration class.")),
50-
$this->newOption(
51-
'controller.oauth-registration',
52-
'class',
53-
'PhabricatorOAuthDefaultRegistrationController')
54-
->setBaseClass('PhabricatorOAuthRegistrationController')
55-
->setDescription(pht("OAuth registration controller.")),
5650
);
5751
}
5852

‎src/applications/people/storage/PhabricatorUser.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ public function sendUsernameChangeEmail(
612612
$new_username = $this->getUserName();
613613

614614
$password_instructions = null;
615-
if (PhabricatorEnv::getEnvConfig('auth.password-auth-enabled')) {
615+
if (PhabricatorAuthProviderPassword::getPasswordProvider()) {
616616
$uri = $this->getEmailLoginURI();
617617
$password_instructions = <<<EOTXT
618618
If you use a password to login, you'll need to reset it before you can login

‎src/applications/settings/panel/PhabricatorSettingsPanelPassword.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function isEnabled() {
2525

2626
// ...or this install doesn't support password authentication at all.
2727

28-
if (!PhabricatorEnv::getEnvConfig('auth.password-auth-enabled')) {
28+
if (!PhabricatorAuthProviderPassword::getPasswordProvider()) {
2929
return false;
3030
}
3131

‎src/docs/configuration/configuration_guide.diviner

+5-2
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,11 @@ Now, navigate to whichever subdomain you set up. You should see instructions to
150150
continue setup. The rest of this document contains additional instructions for
151151
specific setup steps.
152152

153-
When you see the login screen, continue with @{article:Configuring Accounts and
154-
Registration}.
153+
When you resolve any issues and see the welcome screen, enter credentials to
154+
create your initial administrator account. After you log in, you'll want to
155+
configure how other users will be able to log in or register -- until you do,
156+
no one else will be able to sign up or log in. For more information, see
157+
@{article:Configuring Accounts and Registration}.
155158

156159
= Storage: Configuring MySQL =
157160

0 commit comments

Comments
 (0)
Failed to load comments.