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

Very rough edit workflow for AuthProvider configuration

Summary: Ref T1536. Many rough / broken edges, but adds the rough skeleton of the provider edit workflow.

Test Plan: {F46333}

Reviewers: btrahan

Reviewed By: btrahan

CC: aran, chad

Maniphest Tasks: T1536

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

+442 -53
+45 -45
src/__celerity_resource_map__.php
··· 814 814 ), 815 815 'aphront-form-view-css' => 816 816 array( 817 - 'uri' => '/res/40b6b684/rsrc/css/aphront/form-view.css', 817 + 'uri' => '/res/28838b5b/rsrc/css/aphront/form-view.css', 818 818 'type' => 'css', 819 819 'requires' => 820 820 array( ··· 4057 4057 ), array( 4058 4058 'packages' => 4059 4059 array( 4060 - 'f2a3a549' => 4060 + 'cd17ab77' => 4061 4061 array( 4062 4062 'name' => 'core.pkg.css', 4063 4063 'symbols' => ··· 4105 4105 40 => 'phabricator-property-list-view-css', 4106 4106 41 => 'phabricator-tag-view-css', 4107 4107 ), 4108 - 'uri' => '/res/pkg/f2a3a549/core.pkg.css', 4108 + 'uri' => '/res/pkg/cd17ab77/core.pkg.css', 4109 4109 'type' => 'css', 4110 4110 ), 4111 4111 'f2ad0683' => ··· 4299 4299 'reverse' => 4300 4300 array( 4301 4301 'aphront-attached-file-view-css' => 'a7ca34a9', 4302 - 'aphront-dialog-view-css' => 'f2a3a549', 4303 - 'aphront-error-view-css' => 'f2a3a549', 4304 - 'aphront-form-view-css' => 'f2a3a549', 4305 - 'aphront-list-filter-view-css' => 'f2a3a549', 4306 - 'aphront-pager-view-css' => 'f2a3a549', 4307 - 'aphront-panel-view-css' => 'f2a3a549', 4308 - 'aphront-table-view-css' => 'f2a3a549', 4309 - 'aphront-tokenizer-control-css' => 'f2a3a549', 4310 - 'aphront-tooltip-css' => 'f2a3a549', 4311 - 'aphront-typeahead-control-css' => 'f2a3a549', 4302 + 'aphront-dialog-view-css' => 'cd17ab77', 4303 + 'aphront-error-view-css' => 'cd17ab77', 4304 + 'aphront-form-view-css' => 'cd17ab77', 4305 + 'aphront-list-filter-view-css' => 'cd17ab77', 4306 + 'aphront-pager-view-css' => 'cd17ab77', 4307 + 'aphront-panel-view-css' => 'cd17ab77', 4308 + 'aphront-table-view-css' => 'cd17ab77', 4309 + 'aphront-tokenizer-control-css' => 'cd17ab77', 4310 + 'aphront-tooltip-css' => 'cd17ab77', 4311 + 'aphront-typeahead-control-css' => 'cd17ab77', 4312 4312 'differential-changeset-view-css' => 'dd27a69b', 4313 4313 'differential-core-view-css' => 'dd27a69b', 4314 4314 'differential-inline-comment-editor' => '9488bb69', ··· 4322 4322 'differential-table-of-contents-css' => 'dd27a69b', 4323 4323 'diffusion-commit-view-css' => 'c8ce2d88', 4324 4324 'diffusion-icons-css' => 'c8ce2d88', 4325 - 'global-drag-and-drop-css' => 'f2a3a549', 4325 + 'global-drag-and-drop-css' => 'cd17ab77', 4326 4326 'inline-comment-summary-css' => 'dd27a69b', 4327 4327 'javelin-aphlict' => 'f2ad0683', 4328 4328 'javelin-behavior' => 'a9f14d76', ··· 4396 4396 'javelin-util' => 'a9f14d76', 4397 4397 'javelin-vector' => 'a9f14d76', 4398 4398 'javelin-workflow' => 'a9f14d76', 4399 - 'lightbox-attachment-css' => 'f2a3a549', 4399 + 'lightbox-attachment-css' => 'cd17ab77', 4400 4400 'maniphest-task-summary-css' => 'a7ca34a9', 4401 4401 'maniphest-transaction-detail-css' => 'a7ca34a9', 4402 - 'phabricator-action-list-view-css' => 'f2a3a549', 4403 - 'phabricator-application-launch-view-css' => 'f2a3a549', 4402 + 'phabricator-action-list-view-css' => 'cd17ab77', 4403 + 'phabricator-application-launch-view-css' => 'cd17ab77', 4404 4404 'phabricator-busy' => 'f2ad0683', 4405 4405 'phabricator-content-source-view-css' => 'dd27a69b', 4406 - 'phabricator-core-css' => 'f2a3a549', 4407 - 'phabricator-crumbs-view-css' => 'f2a3a549', 4406 + 'phabricator-core-css' => 'cd17ab77', 4407 + 'phabricator-crumbs-view-css' => 'cd17ab77', 4408 4408 'phabricator-drag-and-drop-file-upload' => '9488bb69', 4409 4409 'phabricator-dropdown-menu' => 'f2ad0683', 4410 4410 'phabricator-file-upload' => 'f2ad0683', 4411 - 'phabricator-filetree-view-css' => 'f2a3a549', 4412 - 'phabricator-flag-css' => 'f2a3a549', 4413 - 'phabricator-form-view-css' => 'f2a3a549', 4414 - 'phabricator-header-view-css' => 'f2a3a549', 4411 + 'phabricator-filetree-view-css' => 'cd17ab77', 4412 + 'phabricator-flag-css' => 'cd17ab77', 4413 + 'phabricator-form-view-css' => 'cd17ab77', 4414 + 'phabricator-header-view-css' => 'cd17ab77', 4415 4415 'phabricator-hovercard' => 'f2ad0683', 4416 - 'phabricator-jump-nav' => 'f2a3a549', 4416 + 'phabricator-jump-nav' => 'cd17ab77', 4417 4417 'phabricator-keyboard-shortcut' => 'f2ad0683', 4418 4418 'phabricator-keyboard-shortcut-manager' => 'f2ad0683', 4419 - 'phabricator-main-menu-view' => 'f2a3a549', 4419 + 'phabricator-main-menu-view' => 'cd17ab77', 4420 4420 'phabricator-menu-item' => 'f2ad0683', 4421 - 'phabricator-nav-view-css' => 'f2a3a549', 4421 + 'phabricator-nav-view-css' => 'cd17ab77', 4422 4422 'phabricator-notification' => 'f2ad0683', 4423 - 'phabricator-notification-css' => 'f2a3a549', 4424 - 'phabricator-notification-menu-css' => 'f2a3a549', 4425 - 'phabricator-object-item-list-view-css' => 'f2a3a549', 4423 + 'phabricator-notification-css' => 'cd17ab77', 4424 + 'phabricator-notification-menu-css' => 'cd17ab77', 4425 + 'phabricator-object-item-list-view-css' => 'cd17ab77', 4426 4426 'phabricator-object-selector-css' => 'dd27a69b', 4427 4427 'phabricator-phtize' => 'f2ad0683', 4428 4428 'phabricator-prefab' => 'f2ad0683', 4429 4429 'phabricator-project-tag-css' => 'a7ca34a9', 4430 - 'phabricator-property-list-view-css' => 'f2a3a549', 4431 - 'phabricator-remarkup-css' => 'f2a3a549', 4430 + 'phabricator-property-list-view-css' => 'cd17ab77', 4431 + 'phabricator-remarkup-css' => 'cd17ab77', 4432 4432 'phabricator-shaped-request' => '9488bb69', 4433 - 'phabricator-side-menu-view-css' => 'f2a3a549', 4434 - 'phabricator-standard-page-view' => 'f2a3a549', 4435 - 'phabricator-tag-view-css' => 'f2a3a549', 4433 + 'phabricator-side-menu-view-css' => 'cd17ab77', 4434 + 'phabricator-standard-page-view' => 'cd17ab77', 4435 + 'phabricator-tag-view-css' => 'cd17ab77', 4436 4436 'phabricator-textareautils' => 'f2ad0683', 4437 4437 'phabricator-tooltip' => 'f2ad0683', 4438 - 'phabricator-transaction-view-css' => 'f2a3a549', 4439 - 'phabricator-zindex-css' => 'f2a3a549', 4440 - 'phui-button-css' => 'f2a3a549', 4441 - 'phui-form-css' => 'f2a3a549', 4442 - 'phui-icon-view-css' => 'f2a3a549', 4443 - 'phui-spacing-css' => 'f2a3a549', 4444 - 'sprite-apps-large-css' => 'f2a3a549', 4445 - 'sprite-gradient-css' => 'f2a3a549', 4446 - 'sprite-icons-css' => 'f2a3a549', 4447 - 'sprite-menu-css' => 'f2a3a549', 4448 - 'syntax-highlighting-css' => 'f2a3a549', 4438 + 'phabricator-transaction-view-css' => 'cd17ab77', 4439 + 'phabricator-zindex-css' => 'cd17ab77', 4440 + 'phui-button-css' => 'cd17ab77', 4441 + 'phui-form-css' => 'cd17ab77', 4442 + 'phui-icon-view-css' => 'cd17ab77', 4443 + 'phui-spacing-css' => 'cd17ab77', 4444 + 'sprite-apps-large-css' => 'cd17ab77', 4445 + 'sprite-gradient-css' => 'cd17ab77', 4446 + 'sprite-icons-css' => 'cd17ab77', 4447 + 'sprite-menu-css' => 'cd17ab77', 4448 + 'syntax-highlighting-css' => 'cd17ab77', 4449 4449 ), 4450 4450 ));
+4
src/__phutil_library_map__.php
··· 818 818 'PhabricatorAuthConfirmLinkController' => 'applications/auth/controller/PhabricatorAuthConfirmLinkController.php', 819 819 'PhabricatorAuthController' => 'applications/auth/controller/PhabricatorAuthController.php', 820 820 'PhabricatorAuthDAO' => 'applications/auth/storage/PhabricatorAuthDAO.php', 821 + 'PhabricatorAuthEditController' => 'applications/auth/controller/config/PhabricatorAuthEditController.php', 821 822 'PhabricatorAuthLinkController' => 'applications/auth/controller/PhabricatorAuthLinkController.php', 822 823 'PhabricatorAuthListController' => 'applications/auth/controller/config/PhabricatorAuthListController.php', 823 824 'PhabricatorAuthLoginController' => 'applications/auth/controller/PhabricatorAuthLoginController.php', ··· 825 826 'PhabricatorAuthProvider' => 'applications/auth/provider/PhabricatorAuthProvider.php', 826 827 'PhabricatorAuthProviderConfig' => 'applications/auth/storage/PhabricatorAuthProviderConfig.php', 827 828 'PhabricatorAuthProviderConfigController' => 'applications/auth/controller/config/PhabricatorAuthProviderConfigController.php', 829 + 'PhabricatorAuthProviderConfigEditor' => 'applications/auth/editor/PhabricatorAuthProviderConfigEditor.php', 828 830 'PhabricatorAuthProviderConfigQuery' => 'applications/auth/query/PhabricatorAuthProviderConfigQuery.php', 829 831 'PhabricatorAuthProviderConfigSearchEngine' => 'applications/auth/query/PhabricatorAuthProviderConfigSearchEngine.php', 830 832 'PhabricatorAuthProviderConfigTransaction' => 'applications/auth/storage/PhabricatorAuthProviderConfigTransaction.php', ··· 2692 2694 'PhabricatorAuthConfirmLinkController' => 'PhabricatorAuthController', 2693 2695 'PhabricatorAuthController' => 'PhabricatorController', 2694 2696 'PhabricatorAuthDAO' => 'PhabricatorLiskDAO', 2697 + 'PhabricatorAuthEditController' => 'PhabricatorAuthProviderConfigController', 2695 2698 'PhabricatorAuthLinkController' => 'PhabricatorAuthController', 2696 2699 'PhabricatorAuthListController' => 2697 2700 array( ··· 2706 2709 1 => 'PhabricatorPolicyInterface', 2707 2710 ), 2708 2711 'PhabricatorAuthProviderConfigController' => 'PhabricatorAuthController', 2712 + 'PhabricatorAuthProviderConfigEditor' => 'PhabricatorApplicationTransactionEditor', 2709 2713 'PhabricatorAuthProviderConfigQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 2710 2714 'PhabricatorAuthProviderConfigSearchEngine' => 'PhabricatorApplicationSearchEngine', 2711 2715 'PhabricatorAuthProviderConfigTransaction' => 'PhabricatorApplicationTransaction',
+6 -3
src/applications/auth/application/PhabricatorApplicationAuth.php
··· 38 38 '/auth/' => array( 39 39 /* 40 40 41 - '(query/(?P<key>[^/]+)/)?' => 42 - 'PhabricatorAuthListController', 43 - 'config/new/' => 'PhabricatorAuthNewController', 41 + '(query/(?P<key>[^/]+)/)?' => 'PhabricatorAuthListController', 42 + 'config/' => array( 43 + 'new/' => 'PhabricatorAuthNewController', 44 + 'new/(?P<className>[^/]+)/' => 'PhabricatorAuthEditController', 45 + 'edit/(?P<id>\d+)/' => 'PhabricatorAuthEditController', 46 + ), 44 47 45 48 */ 46 49 'login/(?P<pkey>[^/]+)/' => 'PhabricatorAuthLoginController',
+220
src/applications/auth/controller/config/PhabricatorAuthEditController.php
··· 1 + <?php 2 + 3 + final class PhabricatorAuthEditController 4 + extends PhabricatorAuthProviderConfigController { 5 + 6 + private $providerClass; 7 + private $configID; 8 + 9 + public function willProcessRequest(array $data) { 10 + $this->providerClass = idx($data, 'className'); 11 + $this->configID = idx($data, 'id'); 12 + } 13 + 14 + public function processRequest() { 15 + $request = $this->getRequest(); 16 + $viewer = $request->getUser(); 17 + 18 + $provider = null; 19 + if ($this->configID) { 20 + $config = id(new PhabricatorAuthProviderConfigQuery()) 21 + ->setViewer($viewer) 22 + ->requireCapabilities( 23 + array( 24 + PhabricatorPolicyCapability::CAN_VIEW, 25 + PhabricatorPolicyCapability::CAN_EDIT, 26 + )) 27 + ->withIDs(array($this->configID)) 28 + ->executeOne(); 29 + if (!$config) { 30 + return new Aphront404Response(); 31 + } 32 + 33 + $is_new = false; 34 + } else { 35 + $providers = PhabricatorAuthProvider::getAllBaseProviders(); 36 + foreach ($providers as $candidate_provider) { 37 + if (get_class($candidate_provider) === $this->providerClass) { 38 + $provider = $candidate_provider; 39 + break; 40 + } 41 + } 42 + 43 + if (!$provider) { 44 + return new Aphront404Response(); 45 + } 46 + 47 + // TODO: When we have multi-auth providers, support them here. 48 + 49 + $configs = id(new PhabricatorAuthProviderConfigQuery()) 50 + ->setViewer($viewer) 51 + ->withProviderClasses(array(get_class($provider))) 52 + ->execute(); 53 + 54 + if ($configs) { 55 + // TODO: We could link to the other config's edit interface here. 56 + throw new Exception("This provider is already configured!"); 57 + } 58 + 59 + $config = id(new PhabricatorAuthProviderConfig()) 60 + ->setProviderClass(get_class($provider)) 61 + ->setShouldAllowLogin(1) 62 + ->setShouldAllowRegistration(1) 63 + ->setShouldAllowLink(1) 64 + ->setShouldAllowUnlink(1); 65 + 66 + $is_new = true; 67 + } 68 + 69 + $errors = array(); 70 + 71 + $v_registration = $config->getShouldAllowRegistration(); 72 + $v_link = $config->getShouldAllowLink(); 73 + $v_unlink = $config->getShouldAllowUnlink(); 74 + 75 + if ($request->isFormPost()) { 76 + $xactions = array(); 77 + 78 + if ($is_new) { 79 + $xactions[] = id(new PhabricatorAuthProviderConfigTransaction()) 80 + ->setTransactionType( 81 + PhabricatorAuthProviderConfigTransaction::TYPE_ENABLE) 82 + ->setNewValue(1); 83 + 84 + $config->setProviderType($provider->getProviderType()); 85 + $config->setProviderDomain($provider->getProviderDomain()); 86 + } 87 + 88 + $xactions[] = id(new PhabricatorAuthProviderConfigTransaction()) 89 + ->setTransactionType( 90 + PhabricatorAuthProviderConfigTransaction::TYPE_REGISTRATION) 91 + ->setNewValue($request->getInt('allowRegistration')); 92 + 93 + $xactions[] = id(new PhabricatorAuthProviderConfigTransaction()) 94 + ->setTransactionType( 95 + PhabricatorAuthProviderConfigTransaction::TYPE_LINK) 96 + ->setNewValue($request->getInt('allowLink')); 97 + 98 + $xactions[] = id(new PhabricatorAuthProviderConfigTransaction()) 99 + ->setTransactionType( 100 + PhabricatorAuthProviderConfigTransaction::TYPE_UNLINK) 101 + ->setNewValue($request->getInt('allowUnlink')); 102 + 103 + if (!$errors) { 104 + $editor = id(new PhabricatorAuthProviderConfigEditor()) 105 + ->setActor($viewer) 106 + ->setContentSourceFromRequest($request) 107 + ->setContinueOnNoEffect(true) 108 + ->applyTransactions($config, $xactions); 109 + 110 + return id(new AphrontRedirectResponse())->setURI( 111 + $this->getApplicationURI()); 112 + } 113 + } 114 + 115 + if ($errors) { 116 + $errors = id(new AphrontErrorView())->setErrors($errors); 117 + } 118 + 119 + if ($is_new) { 120 + $button = pht('Add Provider'); 121 + $crumb = pht('Add Provider'); 122 + $title = pht('Add Authentication Provider'); 123 + $cancel_uri = $this->getApplicationURI('/config/new/'); 124 + } else { 125 + $button = pht('Save'); 126 + $crumb = pht('Edit Provider'); 127 + $title = pht('Edit Authentication Provider'); 128 + $cancel_uri = $this->getApplicationURI(); 129 + } 130 + 131 + $str_registration = hsprintf( 132 + '<strong>%s:</strong> %s', 133 + pht('Allow Registration'), 134 + pht( 135 + 'Allow users to register new Phabricator accounts using this '. 136 + 'provider. If you disable registration, users can still use this '. 137 + 'provider to log in to existing accounts, but will not be able to '. 138 + 'create new accounts.')); 139 + 140 + $str_link = hsprintf( 141 + '<strong>%s:</strong> %s', 142 + pht('Allow Linking Accounts'), 143 + pht( 144 + 'Allow users to link account credentials for this provider to '. 145 + 'existing Phabricator accounts. There is normally no reason to '. 146 + 'disable this unless you are trying to move away from a provider '. 147 + 'and want to stop users from creating new account links.')); 148 + 149 + $str_unlink = hsprintf( 150 + '<strong>%s:</strong> %s', 151 + pht('Allow Unlinking Accounts'), 152 + pht( 153 + 'Allow users to unlink account credentials for this provider from '. 154 + 'existing Phabricator accounts. If you disable this, Phabricator '. 155 + 'accounts will be permanently bound to provider accounts.')); 156 + 157 + $form = id(new AphrontFormView()) 158 + ->setUser($viewer) 159 + ->setFlexible(true) 160 + ->appendChild( 161 + id(new AphrontFormStaticControl()) 162 + ->setLabel(pht('Provider')) 163 + ->setValue($provider->getProviderName())) 164 + ->appendChild( 165 + id(new AphrontFormCheckboxControl()) 166 + ->setLabel(pht('Allow')) 167 + ->addCheckbox( 168 + 'allowRegistration', 169 + 1, 170 + $str_registration, 171 + $v_registration)) 172 + ->appendChild( 173 + id(new AphrontFormCheckboxControl()) 174 + ->addCheckbox( 175 + 'allowLink', 176 + 1, 177 + $str_link, 178 + $v_link)) 179 + ->appendChild( 180 + id(new AphrontFormCheckboxControl()) 181 + ->addCheckbox( 182 + 'allowUnlink', 183 + 1, 184 + $str_unlink, 185 + $v_unlink)); 186 + 187 + $provider->extendEditForm($form); 188 + 189 + $form 190 + ->appendChild( 191 + id(new AphrontFormSubmitControl()) 192 + ->addCancelButton($cancel_uri) 193 + ->setValue($button)); 194 + 195 + $crumbs = $this->buildApplicationCrumbs(); 196 + $crumbs->addCrumb( 197 + id(new PhabricatorCrumbView()) 198 + ->setName($crumb)); 199 + 200 + $xaction_view = null; 201 + if (!$is_new) { 202 + $xactions = id(new PhabricatorAuthProviderConfigTransactionQuery()); 203 + // TOOD: ... 204 + } 205 + 206 + return $this->buildApplicationPage( 207 + array( 208 + $crumbs, 209 + $errors, 210 + $form, 211 + $xaction_view 212 + ), 213 + array( 214 + 'title' => $title, 215 + 'dust' => true, 216 + 'device' => true, 217 + )); 218 + } 219 + 220 + }
+8 -1
src/applications/auth/controller/config/PhabricatorAuthListController.php
··· 26 26 27 27 $list = new PhabricatorObjectItemListView(); 28 28 foreach ($configs as $config) { 29 - $item = new PHUIListItemView(); 29 + $item = new PhabricatorObjectItemView(); 30 + 31 + $edit_uri = $this->getApplicationURI('config/edit/'.$config->getID().'/'); 32 + 33 + // TODO: Needs to be built out. 34 + $item 35 + ->setHeader($config->getProviderType()) 36 + ->setHref($edit_uri); 30 37 31 38 $list->addItem($item); 32 39 }
+94
src/applications/auth/editor/PhabricatorAuthProviderConfigEditor.php
··· 1 + <?php 2 + 3 + final class PhabricatorAuthProviderConfigEditor 4 + extends PhabricatorApplicationTransactionEditor { 5 + 6 + public function getTransactionTypes() { 7 + $types = parent::getTransactionTypes(); 8 + 9 + $types[] = PhabricatorAuthProviderConfigTransaction::TYPE_ENABLE; 10 + $types[] = PhabricatorAuthProviderConfigTransaction::TYPE_REGISTRATION; 11 + $types[] = PhabricatorAuthProviderConfigTransaction::TYPE_LINK; 12 + $types[] = PhabricatorAuthProviderConfigTransaction::TYPE_UNLINK; 13 + $types[] = PhabricatorAuthProviderConfigTransaction::TYPE_PROPERTY; 14 + 15 + return $types; 16 + } 17 + 18 + protected function getCustomTransactionOldValue( 19 + PhabricatorLiskDAO $object, 20 + PhabricatorApplicationTransaction $xaction) { 21 + 22 + switch ($xaction->getTransactionType()) { 23 + case PhabricatorAuthProviderConfigTransaction::TYPE_ENABLE: 24 + return $object->getIsEnabled(); 25 + case PhabricatorAuthProviderConfigTransaction::TYPE_REGISTRATION: 26 + return $object->getShouldAllowRegistration(); 27 + case PhabricatorAuthProviderConfigTransaction::TYPE_LINK: 28 + return $object->getShouldAllowLink(); 29 + case PhabricatorAuthProviderConfigTransaction::TYPE_UNLINK: 30 + return $object->getShouldAllowUnlink(); 31 + case PhabricatorAuthProviderConfigTransaction::TYPE_PROPERTY: 32 + // TODO 33 + throw new Exception("TODO"); 34 + } 35 + } 36 + 37 + protected function getCustomTransactionNewValue( 38 + PhabricatorLiskDAO $object, 39 + PhabricatorApplicationTransaction $xaction) { 40 + 41 + switch ($xaction->getTransactionType()) { 42 + case PhabricatorAuthProviderConfigTransaction::TYPE_ENABLE: 43 + case PhabricatorAuthProviderConfigTransaction::TYPE_REGISTRATION: 44 + case PhabricatorAuthProviderConfigTransaction::TYPE_LINK: 45 + case PhabricatorAuthProviderConfigTransaction::TYPE_UNLINK: 46 + case PhabricatorAuthProviderConfigTransaction::TYPE_PROPERTY: 47 + return $xaction->getNewValue(); 48 + } 49 + } 50 + 51 + protected function applyCustomInternalTransaction( 52 + PhabricatorLiskDAO $object, 53 + PhabricatorApplicationTransaction $xaction) { 54 + 55 + $v = $xaction->getNewValue(); 56 + switch ($xaction->getTransactionType()) { 57 + case PhabricatorAuthProviderConfigTransaction::TYPE_ENABLE: 58 + return $object->setIsEnabled($v); 59 + case PhabricatorAuthProviderConfigTransaction::TYPE_REGISTRATION: 60 + return $object->setShouldAllowRegistration($v); 61 + case PhabricatorAuthProviderConfigTransaction::TYPE_LINK: 62 + return $object->setShouldAllowLink($v); 63 + case PhabricatorAuthProviderConfigTransaction::TYPE_UNLINK: 64 + return $object->setShouldAllowUnlink($v); 65 + case PhabricatorAuthProviderConfigTransaction::TYPE_PROPERTY: 66 + // TODO 67 + throw new Exception("TODO"); 68 + } 69 + } 70 + 71 + protected function applyCustomExternalTransaction( 72 + PhabricatorLiskDAO $object, 73 + PhabricatorApplicationTransaction $xaction) { 74 + return; 75 + } 76 + 77 + protected function mergeTransactions( 78 + PhabricatorApplicationTransaction $u, 79 + PhabricatorApplicationTransaction $v) { 80 + 81 + $type = $u->getTransactionType(); 82 + switch ($type) { 83 + case PhabricatorAuthProviderConfigTransaction::TYPE_ENABLE: 84 + case PhabricatorAuthProviderConfigTransaction::TYPE_REGISTRATION: 85 + case PhabricatorAuthProviderConfigTransaction::TYPE_LINK: 86 + case PhabricatorAuthProviderConfigTransaction::TYPE_UNLINK: 87 + // For these types, last transaction wins. 88 + return $v; 89 + } 90 + 91 + return parent::mergeTransactions($u, $v); 92 + } 93 + 94 + }
+5
src/applications/auth/provider/PhabricatorAuthProvider.php
··· 110 110 throw new Exception("Not implemented!"); 111 111 } 112 112 113 + public function extendEditForm(AphrontFormView $form) { 114 + 115 + } 116 + 117 + 113 118 public function createProviders() { 114 119 return array($this); 115 120 }
+31 -1
src/applications/auth/provider/PhabricatorAuthProviderOAuth.php
··· 8 8 abstract protected function getOAuthClientSecret(); 9 9 abstract protected function newOAuthAdapter(); 10 10 11 - 12 11 public function getDescriptionForCreate() { 13 12 return pht('Configure %s OAuth.', $this->getProviderName()); 14 13 } ··· 169 168 } 170 169 171 170 return array($this->loadOrCreateAccount($account_id), $response); 171 + } 172 + 173 + public function extendEditForm( 174 + AphrontFormView $form) { 175 + 176 + $v_id = $this->getOAuthClientID(); 177 + 178 + $secret = $this->getOAuthClientSecret(); 179 + if ($secret) { 180 + $v_secret = str_repeat('*', strlen($secret->openEnvelope())); 181 + } else { 182 + $v_secret = ''; 183 + } 184 + 185 + $e_id = strlen($v_id) ? null : true; 186 + $e_secret = strlen($v_secret) ? null : true; 187 + 188 + $form 189 + ->appendChild( 190 + id(new AphrontFormTextControl()) 191 + ->setLabel(pht('OAuth App ID')) 192 + ->setName('oauth:app:id') 193 + ->setValue($v_id) 194 + ->setError($e_id)) 195 + ->appendChild( 196 + id(new AphrontFormPasswordControl()) 197 + ->setLabel(pht('OAuth App Secret')) 198 + ->setName('oauth:app:secret') 199 + ->setValue($v_secret) 200 + ->setError($e_secret)); 201 + 172 202 } 173 203 174 204 }
+13
src/applications/auth/query/PhabricatorAuthProviderConfigQuery.php
··· 5 5 6 6 private $ids; 7 7 private $phids; 8 + private $providerClasses; 8 9 9 10 const STATUS_ALL = 'status:all'; 10 11 const STATUS_ENABLED = 'status:enabled'; ··· 23 24 24 25 public function withStatus($status) { 25 26 $this->status = $status; 27 + return $this; 28 + } 29 + 30 + public function withProviderClasses(array $classes) { 31 + $this->providerClasses = $classes; 26 32 return $this; 27 33 } 28 34 ··· 63 69 $conn_r, 64 70 'phid IN (%Ls)', 65 71 $this->phids); 72 + } 73 + 74 + if ($this->providerClasses) { 75 + $where[] = qsprintf( 76 + $conn_r, 77 + 'providerClass IN (%Ls)', 78 + $this->providerClasses); 66 79 } 67 80 68 81 $status = $this->status;
+1 -1
src/applications/auth/storage/PhabricatorAuthProviderConfig.php
··· 3 3 final class PhabricatorAuthProviderConfig extends PhabricatorAuthDAO 4 4 implements PhabricatorPolicyInterface { 5 5 6 - protected $phid; 7 6 protected $providerClass; 8 7 protected $providerType; 9 8 protected $providerDomain; ··· 23 22 24 23 public function getConfiguration() { 25 24 return array( 25 + self::CONFIG_AUX_PHID => true, 26 26 self::CONFIG_SERIALIZATION => array( 27 27 'properties' => self::SERIALIZATION_JSON, 28 28 ),
+6
src/applications/auth/storage/PhabricatorAuthProviderConfigTransaction.php
··· 3 3 final class PhabricatorAuthProviderConfigTransaction 4 4 extends PhabricatorApplicationTransaction { 5 5 6 + const TYPE_ENABLE = 'config:enable'; 7 + const TYPE_REGISTRATION = 'config:registration'; 8 + const TYPE_LINK = 'config:link'; 9 + const TYPE_UNLINK = 'config:unlink'; 10 + const TYPE_PROPERTY = 'config:property'; 11 + 6 12 public function getApplicationName() { 7 13 return 'auth'; 8 14 }
+9 -2
webroot/rsrc/css/aphront/form-view.css
··· 178 178 font-size: 13px; 179 179 } 180 180 181 - table.aphront-form-control-radio-layout th, 182 - table.aphront-form-control-checkbox-layout th { 181 + table.aphront-form-control-radio-layout th { 183 182 padding-top: 3px; 184 183 padding-left: 8px; 185 184 padding-bottom: 12px; 186 185 font-weight: bold; 187 186 color: #222222; 188 187 } 188 + 189 + table.aphront-form-control-checkbox-layout th { 190 + padding-top: 2px; 191 + padding-left: 8px; 192 + padding-bottom: 12px; 193 + color: #222222; 194 + } 195 + 189 196 190 197 .aphront-form-control-radio-layout td input, 191 198 .aphront-form-control-checkbox-layout td input {