@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.

Allow MFA factors to provide more guidance text on create workflows

Summary:
Depends on D20016. Ref T920. This does nothing interesting on its own since the TOTP provider has no guidance/warnings, but landing it separately helps to simplify an upcoming SMS diff.

SMS will have these guidance messages:

- "Administrator: you haven't configured any mailer which can send SMS, like Twilio."
- "Administrator: SMS is weak."
- "User: you haven't configured a contact number."

Test Plan: {F6151283} {F6151284}

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T920

Differential Revision: https://secure.phabricator.com/D20017

+88 -10
+6 -6
resources/celerity/map.php
··· 9 9 'names' => array( 10 10 'conpherence.pkg.css' => '3c8a0668', 11 11 'conpherence.pkg.js' => '020aebcf', 12 - 'core.pkg.css' => 'e94cc920', 12 + 'core.pkg.css' => 'a66ea2e7', 13 13 'core.pkg.js' => '5c737607', 14 14 'differential.pkg.css' => 'b8df73d4', 15 15 'differential.pkg.js' => '67c9ea4c', ··· 127 127 'rsrc/css/phui/calendar/phui-calendar-list.css' => 'ccd7e4e2', 128 128 'rsrc/css/phui/calendar/phui-calendar-month.css' => 'cb758c42', 129 129 'rsrc/css/phui/calendar/phui-calendar.css' => 'f11073aa', 130 - 'rsrc/css/phui/object-item/phui-oi-big-ui.css' => 'e5b1fb04', 130 + 'rsrc/css/phui/object-item/phui-oi-big-ui.css' => '9e037c7a', 131 131 'rsrc/css/phui/object-item/phui-oi-color.css' => 'b517bfa0', 132 132 'rsrc/css/phui/object-item/phui-oi-drag-ui.css' => 'da15d3dc', 133 133 'rsrc/css/phui/object-item/phui-oi-flush-ui.css' => '490e2e2e', ··· 832 832 'phui-lightbox-css' => '4ebf22da', 833 833 'phui-list-view-css' => '470b1adb', 834 834 'phui-object-box-css' => '9b58483d', 835 - 'phui-oi-big-ui-css' => 'e5b1fb04', 835 + 'phui-oi-big-ui-css' => '9e037c7a', 836 836 'phui-oi-color-css' => 'b517bfa0', 837 837 'phui-oi-drag-ui-css' => 'da15d3dc', 838 838 'phui-oi-flush-ui-css' => '490e2e2e', ··· 1710 1710 'javelin-uri', 1711 1711 'phabricator-textareautils', 1712 1712 ), 1713 + '9e037c7a' => array( 1714 + 'phui-oi-list-view-css', 1715 + ), 1713 1716 '9f081f05' => array( 1714 1717 'javelin-behavior', 1715 1718 'javelin-dom', ··· 2023 2026 ), 2024 2027 'e562708c' => array( 2025 2028 'javelin-install', 2026 - ), 2027 - 'e5b1fb04' => array( 2028 - 'phui-oi-list-view-css', 2029 2029 ), 2030 2030 'e5bdb730' => array( 2031 2031 'javelin-behavior',
+17 -2
src/applications/auth/controller/mfa/PhabricatorAuthFactorProviderEditController.php
··· 41 41 ->setBig(true) 42 42 ->setFlush(true); 43 43 44 + $factors = msortv($factors, 'newSortVector'); 45 + 44 46 foreach ($factors as $factor_key => $factor) { 45 47 $factor_uri = id(new PhutilURI('/mfa/edit/')) 46 48 ->setQueryParam('providerFactorKey', $factor_key); 47 49 $factor_uri = $this->getApplicationURI($factor_uri); 48 50 51 + $is_enabled = $factor->canCreateNewProvider(); 52 + 49 53 $item = id(new PHUIObjectItemView()) 50 54 ->setHeader($factor->getFactorName()) 51 - ->setHref($factor_uri) 52 - ->setClickable(true) 53 55 ->setImageIcon($factor->newIconView()) 54 56 ->addAttribute($factor->getFactorCreateHelp()); 57 + 58 + if ($is_enabled) { 59 + $item 60 + ->setHref($factor_uri) 61 + ->setClickable(true); 62 + } else { 63 + $item->setDisabled(true); 64 + } 65 + 66 + $create_description = $factor->getProviderCreateDescription(); 67 + if ($create_description) { 68 + $item->appendChild($create_description); 69 + } 55 70 56 71 $menu->addItem($item); 57 72 }
+27
src/applications/auth/factor/PhabricatorAuthFactor.php
··· 45 45 ->setIcon('fa-mobile'); 46 46 } 47 47 48 + public function canCreateNewProvider() { 49 + return true; 50 + } 51 + 52 + public function getProviderCreateDescription() { 53 + return null; 54 + } 55 + 56 + public function canCreateNewConfiguration(PhabricatorUser $user) { 57 + return true; 58 + } 59 + 60 + public function getConfigurationCreateDescription(PhabricatorUser $user) { 61 + return null; 62 + } 63 + 64 + public function getFactorOrder() { 65 + return 1000; 66 + } 67 + 68 + final public function newSortVector() { 69 + return id(new PhutilSortVector()) 70 + ->addInt($this->canCreateNewProvider() ? 0 : 1) 71 + ->addInt($this->getFactorOrder()) 72 + ->addString($this->getFactorName()); 73 + } 74 + 48 75 protected function newChallenge( 49 76 PhabricatorAuthFactorConfig $config, 50 77 PhabricatorUser $viewer) {
+8
src/applications/auth/storage/PhabricatorAuthFactorProvider.php
··· 101 101 return $config; 102 102 } 103 103 104 + public function newSortVector() { 105 + $factor = $this->getFactor(); 106 + 107 + return id(new PhutilSortVector()) 108 + ->addInt($factor->getFactorOrder()) 109 + ->addInt($this->getID()); 110 + } 111 + 104 112 105 113 /* -( PhabricatorApplicationTransactionInterface )------------------------- */ 106 114
+25 -2
src/applications/settings/panel/PhabricatorMultiFactorSettingsPanel.php
··· 169 169 ->addCancelButton($cancel_uri); 170 170 } 171 171 $providers = mpull($providers, null, 'getPHID'); 172 + $proivders = msortv($providers, 'newSortVector'); 172 173 173 174 $token = id(new PhabricatorAuthSessionEngine())->requireHighSecuritySession( 174 175 $viewer, ··· 180 181 $selected_provider = null; 181 182 } else { 182 183 $selected_provider = $providers[$selected_phid]; 184 + 185 + // Only let the user continue creating a factor for a given provider if 186 + // they actually pass the provider's checks. 187 + $selected_factor = $selected_provider->getFactor(); 188 + if (!$selected_factor->canCreateNewConfiguration($viewer)) { 189 + $selected_provider = null; 190 + } 183 191 } 184 192 185 193 if (!$selected_provider) { ··· 192 200 $provider_uri = id(new PhutilURI($this->getPanelURI())) 193 201 ->setQueryParam('providerPHID', $provider_phid); 194 202 203 + $factor = $provider->getFactor(); 204 + $is_enabled = $factor->canCreateNewConfiguration($viewer); 205 + 195 206 $item = id(new PHUIObjectItemView()) 196 207 ->setHeader($provider->getDisplayName()) 197 - ->setHref($provider_uri) 198 - ->setClickable(true) 199 208 ->setImageIcon($provider->newIconView()) 200 209 ->addAttribute($provider->getDisplayDescription()); 210 + 211 + if ($is_enabled) { 212 + $item 213 + ->setHref($provider_uri) 214 + ->setClickable(true); 215 + } else { 216 + $item->setDisabled(true); 217 + } 218 + 219 + $create_description = $factor->getConfigurationCreateDescription( 220 + $viewer); 221 + if ($create_description) { 222 + $item->appendChild($create_description); 223 + } 201 224 202 225 $menu->addItem($item); 203 226 }
+5
webroot/rsrc/css/phui/object-item/phui-oi-big-ui.css
··· 72 72 .device-desktop .phui-oi-linked-container a:hover { 73 73 text-decoration: none; 74 74 } 75 + 76 + /* Spacing for InfoView inside an object item list, like MFA setup. */ 77 + .phui-oi .phui-info-view { 78 + margin: 0 4px 4px; 79 + }