Always allow users to login via email link, even if an install does not use passwords
Summary:
Depends on D20099. Ref T13244. See PHI774. When password auth is enabled, we support a standard email-based account recovery mechanism with "Forgot password?".
When password auth is not enabled, we disable the self-serve version of this mechanism. You can still get email account login links via "Send Welcome Mail" or "bin/auth recover".
There's no real technical, product, or security reason not to let everyone do email login all the time. On the technical front, these links already work and are used in other contexts. On the product front, we just need to tweak a couple of strings.
On the security front, there's some argument that this mechanism provides more overall surface area for an attacker, but if we find that argument compelling we should probably provide a way to disable the self-serve pathway in all cases, rather than coupling it to which providers are enabled.
Also, inch toward having things iterate over configurations (saved database objects) instead of providers (abstract implementations) so we can some day live in a world where we support multiple configurations of the same provider type (T6703).
Test Plan:
- With password auth enabled, reset password.
- Without password auth enabled, did an email login recovery.
{F6184910}
Reviewers: amckinley
Reviewed By: amckinley
Maniphest Tasks: T13244
Differential Revision: https://secure.phabricator.com/D20100
This commit is contained in:
@@ -75,6 +75,11 @@ final class PhabricatorAuthStartController
|
||||
}
|
||||
}
|
||||
|
||||
$configs = array();
|
||||
foreach ($providers as $provider) {
|
||||
$configs[] = $provider->getProviderConfig();
|
||||
}
|
||||
|
||||
if (!$providers) {
|
||||
if ($this->isFirstTimeSetup()) {
|
||||
// If this is a fresh install, let the user register their admin
|
||||
@@ -179,6 +184,8 @@ final class PhabricatorAuthStartController
|
||||
|
||||
$custom_message = $this->newCustomStartMessage();
|
||||
|
||||
$email_login = $this->newEmailLoginView($configs);
|
||||
|
||||
$crumbs = $this->buildApplicationCrumbs();
|
||||
$crumbs->addTextCrumb(pht('Login'));
|
||||
$crumbs->setBorder(true);
|
||||
@@ -188,6 +195,7 @@ final class PhabricatorAuthStartController
|
||||
$invite_message,
|
||||
$custom_message,
|
||||
$out,
|
||||
$email_login,
|
||||
);
|
||||
|
||||
return $this->newPage()
|
||||
@@ -311,4 +319,43 @@ final class PhabricatorAuthStartController
|
||||
$remarkup_view);
|
||||
}
|
||||
|
||||
private function newEmailLoginView(array $configs) {
|
||||
assert_instances_of($configs, 'PhabricatorAuthProviderConfig');
|
||||
|
||||
// Check if password auth is enabled. If it is, the password login form
|
||||
// renders a "Forgot password?" link, so we don't need to provide a
|
||||
// supplemental link.
|
||||
|
||||
$has_password = false;
|
||||
foreach ($configs as $config) {
|
||||
$provider = $config->getProvider();
|
||||
if ($provider instanceof PhabricatorPasswordAuthProvider) {
|
||||
$has_password = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($has_password) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$view = array(
|
||||
pht('Trouble logging in?'),
|
||||
' ',
|
||||
phutil_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => '/login/email/',
|
||||
),
|
||||
pht('Send a login link to your email address.')),
|
||||
);
|
||||
|
||||
return phutil_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => 'auth-custom-message',
|
||||
),
|
||||
$view);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user