@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+69
+19
src/applications/auth/factor/PhabricatorAuthFactor.php
··· 3 3 abstract class PhabricatorAuthFactor extends Phobject { 4 4 5 5 abstract public function getFactorName(); 6 + abstract public function getFactorShortName(); 6 7 abstract public function getFactorKey(); 7 8 abstract public function getFactorCreateHelp(); 8 9 abstract public function getFactorDescription(); ··· 63 64 public function getConfigurationCreateDescription( 64 65 PhabricatorAuthFactorProvider $provider, 65 66 PhabricatorUser $user) { 67 + return null; 68 + } 69 + 70 + public function getConfigurationListDetails( 71 + PhabricatorAuthFactorConfig $config, 72 + PhabricatorAuthFactorProvider $provider, 73 + PhabricatorUser $viewer) { 66 74 return null; 67 75 } 68 76 ··· 522 530 } 523 531 524 532 return $request->validateCSRF(); 533 + } 534 + 535 + final protected function loadConfigurationsForProvider( 536 + PhabricatorAuthFactorProvider $provider, 537 + PhabricatorUser $user) { 538 + 539 + return id(new PhabricatorAuthFactorConfigQuery()) 540 + ->setViewer($user) 541 + ->withUserPHIDs(array($user->getPHID())) 542 + ->withFactorProviderPHIDs(array($provider->getPHID())) 543 + ->execute(); 525 544 } 526 545 527 546 }
+18
src/applications/auth/factor/PhabricatorSMSAuthFactor.php
··· 8 8 } 9 9 10 10 public function getFactorName() { 11 + return pht('Text Message (SMS)'); 12 + } 13 + 14 + public function getFactorShortName() { 11 15 return pht('SMS'); 12 16 } 13 17 ··· 75 79 return false; 76 80 } 77 81 82 + if ($this->loadConfigurationsForProvider($provider, $user)) { 83 + return false; 84 + } 85 + 78 86 return true; 79 87 } 80 88 ··· 93 101 'You have not configured a primary contact number. Configure '. 94 102 'a contact number before adding SMS as an authentication '. 95 103 'factor.'), 104 + )); 105 + } 106 + 107 + if ($this->loadConfigurationsForProvider($provider, $user)) { 108 + $messages[] = id(new PHUIInfoView()) 109 + ->setSeverity(PHUIInfoView::SEVERITY_WARNING) 110 + ->setErrors( 111 + array( 112 + pht( 113 + 'You already have SMS authentication attached to your account.'), 96 114 )); 97 115 } 98 116
+13
src/applications/auth/factor/PhabricatorTOTPAuthFactor.php
··· 10 10 return pht('Mobile Phone App (TOTP)'); 11 11 } 12 12 13 + public function getFactorShortName() { 14 + return pht('TOTP'); 15 + } 16 + 13 17 public function getFactorCreateHelp() { 14 18 return pht( 15 19 'Allow users to attach a mobile authenticator application (like '. ··· 36 40 'If you haven\'t already, download and install a TOTP application on '. 37 41 'your phone now. Once you\'ve launched the application and are ready '. 38 42 'to add a new TOTP code, continue to the next step.'); 43 + } 44 + 45 + public function getConfigurationListDetails( 46 + PhabricatorAuthFactorConfig $config, 47 + PhabricatorAuthFactorProvider $provider, 48 + PhabricatorUser $viewer) { 49 + 50 + $bits = strlen($config->getFactorSecret()) * 8; 51 + return pht('%d-Bit Secret', $bits); 39 52 } 40 53 41 54 public function processAddFactorForm(
+9
src/applications/auth/storage/PhabricatorAuthFactorProvider.php
··· 126 126 return $this->getFactor()->getConfigurationCreateDescription($this, $user); 127 127 } 128 128 129 + public function getConfigurationListDetails( 130 + PhabricatorAuthFactorConfig $config, 131 + PhabricatorUser $viewer) { 132 + return $this->getFactor()->getConfigurationListDetails( 133 + $config, 134 + $this, 135 + $viewer); 136 + } 137 + 129 138 130 139 /* -( PhabricatorApplicationTransactionInterface )------------------------- */ 131 140
+10
src/applications/settings/panel/PhabricatorMultiFactorSettingsPanel.php
··· 77 77 ->setIcon("{$status_icon} {$status_color}") 78 78 ->setTooltip(pht('Provider: %s', $status->getName())); 79 79 80 + $details = $provider->getConfigurationListDetails($factor, $viewer); 81 + 80 82 $rows[] = array( 81 83 $icon, 82 84 javelin_tag( ··· 86 88 'sigil' => 'workflow', 87 89 ), 88 90 $factor->getFactorName()), 91 + $provider->getFactor()->getFactorShortName(), 89 92 $provider->getDisplayName(), 93 + $details, 90 94 phabricator_datetime($factor->getDateCreated(), $viewer), 91 95 javelin_tag( 92 96 'a', ··· 107 111 null, 108 112 pht('Name'), 109 113 pht('Type'), 114 + pht('Provider'), 115 + pht('Details'), 110 116 pht('Created'), 111 117 null, 112 118 )); ··· 114 120 array( 115 121 null, 116 122 'wide pri', 123 + null, 124 + null, 117 125 null, 118 126 'right', 119 127 'action', ··· 123 131 array( 124 132 true, 125 133 true, 134 + false, 135 + false, 126 136 false, 127 137 false, 128 138 true,