Page MenuHomePhabricator

D20034.id47862.diff
No OneTemporary

D20034.id47862.diff

diff --git a/src/applications/auth/factor/PhabricatorAuthFactor.php b/src/applications/auth/factor/PhabricatorAuthFactor.php
--- a/src/applications/auth/factor/PhabricatorAuthFactor.php
+++ b/src/applications/auth/factor/PhabricatorAuthFactor.php
@@ -3,6 +3,7 @@
abstract class PhabricatorAuthFactor extends Phobject {
abstract public function getFactorName();
+ abstract public function getFactorShortName();
abstract public function getFactorKey();
abstract public function getFactorCreateHelp();
abstract public function getFactorDescription();
@@ -66,6 +67,13 @@
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?
*
@@ -524,4 +532,15 @@
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();
+ }
+
}
diff --git a/src/applications/auth/factor/PhabricatorSMSAuthFactor.php b/src/applications/auth/factor/PhabricatorSMSAuthFactor.php
--- a/src/applications/auth/factor/PhabricatorSMSAuthFactor.php
+++ b/src/applications/auth/factor/PhabricatorSMSAuthFactor.php
@@ -8,6 +8,10 @@
}
public function getFactorName() {
+ return pht('Text Message (SMS)');
+ }
+
+ public function getFactorShortName() {
return pht('SMS');
}
@@ -75,6 +79,10 @@
return false;
}
+ if ($this->loadConfigurationsForProvider($provider, $user)) {
+ return false;
+ }
+
return true;
}
@@ -96,6 +104,16 @@
));
}
+ 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;
}
diff --git a/src/applications/auth/factor/PhabricatorTOTPAuthFactor.php b/src/applications/auth/factor/PhabricatorTOTPAuthFactor.php
--- a/src/applications/auth/factor/PhabricatorTOTPAuthFactor.php
+++ b/src/applications/auth/factor/PhabricatorTOTPAuthFactor.php
@@ -10,6 +10,10 @@
return pht('Mobile Phone App (TOTP)');
}
+ public function getFactorShortName() {
+ return pht('TOTP');
+ }
+
public function getFactorCreateHelp() {
return pht(
'Allow users to attach a mobile authenticator application (like '.
@@ -38,6 +42,15 @@
'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(
PhabricatorAuthFactorProvider $provider,
AphrontFormView $form,
diff --git a/src/applications/auth/storage/PhabricatorAuthFactorProvider.php b/src/applications/auth/storage/PhabricatorAuthFactorProvider.php
--- a/src/applications/auth/storage/PhabricatorAuthFactorProvider.php
+++ b/src/applications/auth/storage/PhabricatorAuthFactorProvider.php
@@ -126,6 +126,15 @@
return $this->getFactor()->getConfigurationCreateDescription($this, $user);
}
+ public function getConfigurationListDetails(
+ PhabricatorAuthFactorConfig $config,
+ PhabricatorUser $viewer) {
+ return $this->getFactor()->getConfigurationListDetails(
+ $config,
+ $this,
+ $viewer);
+ }
+
/* -( PhabricatorApplicationTransactionInterface )------------------------- */
diff --git a/src/applications/settings/panel/PhabricatorMultiFactorSettingsPanel.php b/src/applications/settings/panel/PhabricatorMultiFactorSettingsPanel.php
--- a/src/applications/settings/panel/PhabricatorMultiFactorSettingsPanel.php
+++ b/src/applications/settings/panel/PhabricatorMultiFactorSettingsPanel.php
@@ -77,6 +77,8 @@
->setIcon("{$status_icon} {$status_color}")
->setTooltip(pht('Provider: %s', $status->getName()));
+ $details = $provider->getConfigurationListDetails($factor, $viewer);
+
$rows[] = array(
$icon,
javelin_tag(
@@ -86,7 +88,9 @@
'sigil' => 'workflow',
),
$factor->getFactorName()),
+ $provider->getFactor()->getFactorShortName(),
$provider->getDisplayName(),
+ $details,
phabricator_datetime($factor->getDateCreated(), $viewer),
javelin_tag(
'a',
@@ -107,6 +111,8 @@
null,
pht('Name'),
pht('Type'),
+ pht('Provider'),
+ pht('Details'),
pht('Created'),
null,
));
@@ -115,6 +121,8 @@
null,
'wide pri',
null,
+ null,
+ null,
'right',
'action',
));
@@ -125,6 +133,8 @@
true,
false,
false,
+ false,
+ false,
true,
));

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 2, 7:39 PM (2 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6712629
Default Alt Text
D20034.id47862.diff (5 KB)

Event Timeline