Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14397287
D20034.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D20034.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Mon, Dec 23, 10:04 AM (17 h, 35 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6920180
Default Alt Text
D20034.diff (5 KB)
Attached To
Mode
D20034: Add more factor details to the Settings factor list
Attached
Detach File
Event Timeline
Log In to Comment