mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-02 09:58:24 +01:00
Add more factor details to the Settings factor list
Summary: Depends on D20033. Ref T13222. Flesh this UI out a bit, and provide bit-strength information for TOTP. Also, stop users from adding multiple SMS factors since this is pointless (they all always text your primary contact number). Test Plan: {F6156245} {F6156246} Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13222 Differential Revision: https://secure.phabricator.com/D20034
This commit is contained in:
parent
2dd8a0fc69
commit
bce44385e1
5 changed files with 69 additions and 0 deletions
|
@ -3,6 +3,7 @@
|
||||||
abstract class PhabricatorAuthFactor extends Phobject {
|
abstract class PhabricatorAuthFactor extends Phobject {
|
||||||
|
|
||||||
abstract public function getFactorName();
|
abstract public function getFactorName();
|
||||||
|
abstract public function getFactorShortName();
|
||||||
abstract public function getFactorKey();
|
abstract public function getFactorKey();
|
||||||
abstract public function getFactorCreateHelp();
|
abstract public function getFactorCreateHelp();
|
||||||
abstract public function getFactorDescription();
|
abstract public function getFactorDescription();
|
||||||
|
@ -66,6 +67,13 @@ abstract class PhabricatorAuthFactor extends Phobject {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getConfigurationListDetails(
|
||||||
|
PhabricatorAuthFactorConfig $config,
|
||||||
|
PhabricatorAuthFactorProvider $provider,
|
||||||
|
PhabricatorUser $viewer) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is this a factor which depends on the user's contact number?
|
* Is this a factor which depends on the user's contact number?
|
||||||
*
|
*
|
||||||
|
@ -524,4 +532,15 @@ abstract class PhabricatorAuthFactor extends Phobject {
|
||||||
return $request->validateCSRF();
|
return $request->validateCSRF();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final protected function loadConfigurationsForProvider(
|
||||||
|
PhabricatorAuthFactorProvider $provider,
|
||||||
|
PhabricatorUser $user) {
|
||||||
|
|
||||||
|
return id(new PhabricatorAuthFactorConfigQuery())
|
||||||
|
->setViewer($user)
|
||||||
|
->withUserPHIDs(array($user->getPHID()))
|
||||||
|
->withFactorProviderPHIDs(array($provider->getPHID()))
|
||||||
|
->execute();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,10 @@ final class PhabricatorSMSAuthFactor
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFactorName() {
|
public function getFactorName() {
|
||||||
|
return pht('Text Message (SMS)');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFactorShortName() {
|
||||||
return pht('SMS');
|
return pht('SMS');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,6 +79,10 @@ final class PhabricatorSMSAuthFactor
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->loadConfigurationsForProvider($provider, $user)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,6 +104,16 @@ final class PhabricatorSMSAuthFactor
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->loadConfigurationsForProvider($provider, $user)) {
|
||||||
|
$messages[] = id(new PHUIInfoView())
|
||||||
|
->setSeverity(PHUIInfoView::SEVERITY_WARNING)
|
||||||
|
->setErrors(
|
||||||
|
array(
|
||||||
|
pht(
|
||||||
|
'You already have SMS authentication attached to your account.'),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
return $messages;
|
return $messages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,10 @@ final class PhabricatorTOTPAuthFactor extends PhabricatorAuthFactor {
|
||||||
return pht('Mobile Phone App (TOTP)');
|
return pht('Mobile Phone App (TOTP)');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getFactorShortName() {
|
||||||
|
return pht('TOTP');
|
||||||
|
}
|
||||||
|
|
||||||
public function getFactorCreateHelp() {
|
public function getFactorCreateHelp() {
|
||||||
return pht(
|
return pht(
|
||||||
'Allow users to attach a mobile authenticator application (like '.
|
'Allow users to attach a mobile authenticator application (like '.
|
||||||
|
@ -38,6 +42,15 @@ final class PhabricatorTOTPAuthFactor extends PhabricatorAuthFactor {
|
||||||
'to add a new TOTP code, continue to the next step.');
|
'to add a new TOTP code, continue to the next step.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getConfigurationListDetails(
|
||||||
|
PhabricatorAuthFactorConfig $config,
|
||||||
|
PhabricatorAuthFactorProvider $provider,
|
||||||
|
PhabricatorUser $viewer) {
|
||||||
|
|
||||||
|
$bits = strlen($config->getFactorSecret()) * 8;
|
||||||
|
return pht('%d-Bit Secret', $bits);
|
||||||
|
}
|
||||||
|
|
||||||
public function processAddFactorForm(
|
public function processAddFactorForm(
|
||||||
PhabricatorAuthFactorProvider $provider,
|
PhabricatorAuthFactorProvider $provider,
|
||||||
AphrontFormView $form,
|
AphrontFormView $form,
|
||||||
|
|
|
@ -126,6 +126,15 @@ final class PhabricatorAuthFactorProvider
|
||||||
return $this->getFactor()->getConfigurationCreateDescription($this, $user);
|
return $this->getFactor()->getConfigurationCreateDescription($this, $user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getConfigurationListDetails(
|
||||||
|
PhabricatorAuthFactorConfig $config,
|
||||||
|
PhabricatorUser $viewer) {
|
||||||
|
return $this->getFactor()->getConfigurationListDetails(
|
||||||
|
$config,
|
||||||
|
$this,
|
||||||
|
$viewer);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* -( PhabricatorApplicationTransactionInterface )------------------------- */
|
/* -( PhabricatorApplicationTransactionInterface )------------------------- */
|
||||||
|
|
||||||
|
|
|
@ -77,6 +77,8 @@ final class PhabricatorMultiFactorSettingsPanel
|
||||||
->setIcon("{$status_icon} {$status_color}")
|
->setIcon("{$status_icon} {$status_color}")
|
||||||
->setTooltip(pht('Provider: %s', $status->getName()));
|
->setTooltip(pht('Provider: %s', $status->getName()));
|
||||||
|
|
||||||
|
$details = $provider->getConfigurationListDetails($factor, $viewer);
|
||||||
|
|
||||||
$rows[] = array(
|
$rows[] = array(
|
||||||
$icon,
|
$icon,
|
||||||
javelin_tag(
|
javelin_tag(
|
||||||
|
@ -86,7 +88,9 @@ final class PhabricatorMultiFactorSettingsPanel
|
||||||
'sigil' => 'workflow',
|
'sigil' => 'workflow',
|
||||||
),
|
),
|
||||||
$factor->getFactorName()),
|
$factor->getFactorName()),
|
||||||
|
$provider->getFactor()->getFactorShortName(),
|
||||||
$provider->getDisplayName(),
|
$provider->getDisplayName(),
|
||||||
|
$details,
|
||||||
phabricator_datetime($factor->getDateCreated(), $viewer),
|
phabricator_datetime($factor->getDateCreated(), $viewer),
|
||||||
javelin_tag(
|
javelin_tag(
|
||||||
'a',
|
'a',
|
||||||
|
@ -107,6 +111,8 @@ final class PhabricatorMultiFactorSettingsPanel
|
||||||
null,
|
null,
|
||||||
pht('Name'),
|
pht('Name'),
|
||||||
pht('Type'),
|
pht('Type'),
|
||||||
|
pht('Provider'),
|
||||||
|
pht('Details'),
|
||||||
pht('Created'),
|
pht('Created'),
|
||||||
null,
|
null,
|
||||||
));
|
));
|
||||||
|
@ -115,6 +121,8 @@ final class PhabricatorMultiFactorSettingsPanel
|
||||||
null,
|
null,
|
||||||
'wide pri',
|
'wide pri',
|
||||||
null,
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
'right',
|
'right',
|
||||||
'action',
|
'action',
|
||||||
));
|
));
|
||||||
|
@ -125,6 +133,8 @@ final class PhabricatorMultiFactorSettingsPanel
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
true,
|
true,
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue