mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 00:32:42 +01:00
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
This commit is contained in:
parent
abb367dd5b
commit
c6374e25d5
12 changed files with 442 additions and 53 deletions
|
@ -814,7 +814,7 @@ celerity_register_resource_map(array(
|
|||
),
|
||||
'aphront-form-view-css' =>
|
||||
array(
|
||||
'uri' => '/res/40b6b684/rsrc/css/aphront/form-view.css',
|
||||
'uri' => '/res/28838b5b/rsrc/css/aphront/form-view.css',
|
||||
'type' => 'css',
|
||||
'requires' =>
|
||||
array(
|
||||
|
@ -4057,7 +4057,7 @@ celerity_register_resource_map(array(
|
|||
), array(
|
||||
'packages' =>
|
||||
array(
|
||||
'f2a3a549' =>
|
||||
'cd17ab77' =>
|
||||
array(
|
||||
'name' => 'core.pkg.css',
|
||||
'symbols' =>
|
||||
|
@ -4105,7 +4105,7 @@ celerity_register_resource_map(array(
|
|||
40 => 'phabricator-property-list-view-css',
|
||||
41 => 'phabricator-tag-view-css',
|
||||
),
|
||||
'uri' => '/res/pkg/f2a3a549/core.pkg.css',
|
||||
'uri' => '/res/pkg/cd17ab77/core.pkg.css',
|
||||
'type' => 'css',
|
||||
),
|
||||
'f2ad0683' =>
|
||||
|
@ -4299,16 +4299,16 @@ celerity_register_resource_map(array(
|
|||
'reverse' =>
|
||||
array(
|
||||
'aphront-attached-file-view-css' => 'a7ca34a9',
|
||||
'aphront-dialog-view-css' => 'f2a3a549',
|
||||
'aphront-error-view-css' => 'f2a3a549',
|
||||
'aphront-form-view-css' => 'f2a3a549',
|
||||
'aphront-list-filter-view-css' => 'f2a3a549',
|
||||
'aphront-pager-view-css' => 'f2a3a549',
|
||||
'aphront-panel-view-css' => 'f2a3a549',
|
||||
'aphront-table-view-css' => 'f2a3a549',
|
||||
'aphront-tokenizer-control-css' => 'f2a3a549',
|
||||
'aphront-tooltip-css' => 'f2a3a549',
|
||||
'aphront-typeahead-control-css' => 'f2a3a549',
|
||||
'aphront-dialog-view-css' => 'cd17ab77',
|
||||
'aphront-error-view-css' => 'cd17ab77',
|
||||
'aphront-form-view-css' => 'cd17ab77',
|
||||
'aphront-list-filter-view-css' => 'cd17ab77',
|
||||
'aphront-pager-view-css' => 'cd17ab77',
|
||||
'aphront-panel-view-css' => 'cd17ab77',
|
||||
'aphront-table-view-css' => 'cd17ab77',
|
||||
'aphront-tokenizer-control-css' => 'cd17ab77',
|
||||
'aphront-tooltip-css' => 'cd17ab77',
|
||||
'aphront-typeahead-control-css' => 'cd17ab77',
|
||||
'differential-changeset-view-css' => 'dd27a69b',
|
||||
'differential-core-view-css' => 'dd27a69b',
|
||||
'differential-inline-comment-editor' => '9488bb69',
|
||||
|
@ -4322,7 +4322,7 @@ celerity_register_resource_map(array(
|
|||
'differential-table-of-contents-css' => 'dd27a69b',
|
||||
'diffusion-commit-view-css' => 'c8ce2d88',
|
||||
'diffusion-icons-css' => 'c8ce2d88',
|
||||
'global-drag-and-drop-css' => 'f2a3a549',
|
||||
'global-drag-and-drop-css' => 'cd17ab77',
|
||||
'inline-comment-summary-css' => 'dd27a69b',
|
||||
'javelin-aphlict' => 'f2ad0683',
|
||||
'javelin-behavior' => 'a9f14d76',
|
||||
|
@ -4396,55 +4396,55 @@ celerity_register_resource_map(array(
|
|||
'javelin-util' => 'a9f14d76',
|
||||
'javelin-vector' => 'a9f14d76',
|
||||
'javelin-workflow' => 'a9f14d76',
|
||||
'lightbox-attachment-css' => 'f2a3a549',
|
||||
'lightbox-attachment-css' => 'cd17ab77',
|
||||
'maniphest-task-summary-css' => 'a7ca34a9',
|
||||
'maniphest-transaction-detail-css' => 'a7ca34a9',
|
||||
'phabricator-action-list-view-css' => 'f2a3a549',
|
||||
'phabricator-application-launch-view-css' => 'f2a3a549',
|
||||
'phabricator-action-list-view-css' => 'cd17ab77',
|
||||
'phabricator-application-launch-view-css' => 'cd17ab77',
|
||||
'phabricator-busy' => 'f2ad0683',
|
||||
'phabricator-content-source-view-css' => 'dd27a69b',
|
||||
'phabricator-core-css' => 'f2a3a549',
|
||||
'phabricator-crumbs-view-css' => 'f2a3a549',
|
||||
'phabricator-core-css' => 'cd17ab77',
|
||||
'phabricator-crumbs-view-css' => 'cd17ab77',
|
||||
'phabricator-drag-and-drop-file-upload' => '9488bb69',
|
||||
'phabricator-dropdown-menu' => 'f2ad0683',
|
||||
'phabricator-file-upload' => 'f2ad0683',
|
||||
'phabricator-filetree-view-css' => 'f2a3a549',
|
||||
'phabricator-flag-css' => 'f2a3a549',
|
||||
'phabricator-form-view-css' => 'f2a3a549',
|
||||
'phabricator-header-view-css' => 'f2a3a549',
|
||||
'phabricator-filetree-view-css' => 'cd17ab77',
|
||||
'phabricator-flag-css' => 'cd17ab77',
|
||||
'phabricator-form-view-css' => 'cd17ab77',
|
||||
'phabricator-header-view-css' => 'cd17ab77',
|
||||
'phabricator-hovercard' => 'f2ad0683',
|
||||
'phabricator-jump-nav' => 'f2a3a549',
|
||||
'phabricator-jump-nav' => 'cd17ab77',
|
||||
'phabricator-keyboard-shortcut' => 'f2ad0683',
|
||||
'phabricator-keyboard-shortcut-manager' => 'f2ad0683',
|
||||
'phabricator-main-menu-view' => 'f2a3a549',
|
||||
'phabricator-main-menu-view' => 'cd17ab77',
|
||||
'phabricator-menu-item' => 'f2ad0683',
|
||||
'phabricator-nav-view-css' => 'f2a3a549',
|
||||
'phabricator-nav-view-css' => 'cd17ab77',
|
||||
'phabricator-notification' => 'f2ad0683',
|
||||
'phabricator-notification-css' => 'f2a3a549',
|
||||
'phabricator-notification-menu-css' => 'f2a3a549',
|
||||
'phabricator-object-item-list-view-css' => 'f2a3a549',
|
||||
'phabricator-notification-css' => 'cd17ab77',
|
||||
'phabricator-notification-menu-css' => 'cd17ab77',
|
||||
'phabricator-object-item-list-view-css' => 'cd17ab77',
|
||||
'phabricator-object-selector-css' => 'dd27a69b',
|
||||
'phabricator-phtize' => 'f2ad0683',
|
||||
'phabricator-prefab' => 'f2ad0683',
|
||||
'phabricator-project-tag-css' => 'a7ca34a9',
|
||||
'phabricator-property-list-view-css' => 'f2a3a549',
|
||||
'phabricator-remarkup-css' => 'f2a3a549',
|
||||
'phabricator-property-list-view-css' => 'cd17ab77',
|
||||
'phabricator-remarkup-css' => 'cd17ab77',
|
||||
'phabricator-shaped-request' => '9488bb69',
|
||||
'phabricator-side-menu-view-css' => 'f2a3a549',
|
||||
'phabricator-standard-page-view' => 'f2a3a549',
|
||||
'phabricator-tag-view-css' => 'f2a3a549',
|
||||
'phabricator-side-menu-view-css' => 'cd17ab77',
|
||||
'phabricator-standard-page-view' => 'cd17ab77',
|
||||
'phabricator-tag-view-css' => 'cd17ab77',
|
||||
'phabricator-textareautils' => 'f2ad0683',
|
||||
'phabricator-tooltip' => 'f2ad0683',
|
||||
'phabricator-transaction-view-css' => 'f2a3a549',
|
||||
'phabricator-zindex-css' => 'f2a3a549',
|
||||
'phui-button-css' => 'f2a3a549',
|
||||
'phui-form-css' => 'f2a3a549',
|
||||
'phui-icon-view-css' => 'f2a3a549',
|
||||
'phui-spacing-css' => 'f2a3a549',
|
||||
'sprite-apps-large-css' => 'f2a3a549',
|
||||
'sprite-gradient-css' => 'f2a3a549',
|
||||
'sprite-icons-css' => 'f2a3a549',
|
||||
'sprite-menu-css' => 'f2a3a549',
|
||||
'syntax-highlighting-css' => 'f2a3a549',
|
||||
'phabricator-transaction-view-css' => 'cd17ab77',
|
||||
'phabricator-zindex-css' => 'cd17ab77',
|
||||
'phui-button-css' => 'cd17ab77',
|
||||
'phui-form-css' => 'cd17ab77',
|
||||
'phui-icon-view-css' => 'cd17ab77',
|
||||
'phui-spacing-css' => 'cd17ab77',
|
||||
'sprite-apps-large-css' => 'cd17ab77',
|
||||
'sprite-gradient-css' => 'cd17ab77',
|
||||
'sprite-icons-css' => 'cd17ab77',
|
||||
'sprite-menu-css' => 'cd17ab77',
|
||||
'syntax-highlighting-css' => 'cd17ab77',
|
||||
),
|
||||
));
|
||||
|
|
|
@ -818,6 +818,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorAuthConfirmLinkController' => 'applications/auth/controller/PhabricatorAuthConfirmLinkController.php',
|
||||
'PhabricatorAuthController' => 'applications/auth/controller/PhabricatorAuthController.php',
|
||||
'PhabricatorAuthDAO' => 'applications/auth/storage/PhabricatorAuthDAO.php',
|
||||
'PhabricatorAuthEditController' => 'applications/auth/controller/config/PhabricatorAuthEditController.php',
|
||||
'PhabricatorAuthLinkController' => 'applications/auth/controller/PhabricatorAuthLinkController.php',
|
||||
'PhabricatorAuthListController' => 'applications/auth/controller/config/PhabricatorAuthListController.php',
|
||||
'PhabricatorAuthLoginController' => 'applications/auth/controller/PhabricatorAuthLoginController.php',
|
||||
|
@ -825,6 +826,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorAuthProvider' => 'applications/auth/provider/PhabricatorAuthProvider.php',
|
||||
'PhabricatorAuthProviderConfig' => 'applications/auth/storage/PhabricatorAuthProviderConfig.php',
|
||||
'PhabricatorAuthProviderConfigController' => 'applications/auth/controller/config/PhabricatorAuthProviderConfigController.php',
|
||||
'PhabricatorAuthProviderConfigEditor' => 'applications/auth/editor/PhabricatorAuthProviderConfigEditor.php',
|
||||
'PhabricatorAuthProviderConfigQuery' => 'applications/auth/query/PhabricatorAuthProviderConfigQuery.php',
|
||||
'PhabricatorAuthProviderConfigSearchEngine' => 'applications/auth/query/PhabricatorAuthProviderConfigSearchEngine.php',
|
||||
'PhabricatorAuthProviderConfigTransaction' => 'applications/auth/storage/PhabricatorAuthProviderConfigTransaction.php',
|
||||
|
@ -2692,6 +2694,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorAuthConfirmLinkController' => 'PhabricatorAuthController',
|
||||
'PhabricatorAuthController' => 'PhabricatorController',
|
||||
'PhabricatorAuthDAO' => 'PhabricatorLiskDAO',
|
||||
'PhabricatorAuthEditController' => 'PhabricatorAuthProviderConfigController',
|
||||
'PhabricatorAuthLinkController' => 'PhabricatorAuthController',
|
||||
'PhabricatorAuthListController' =>
|
||||
array(
|
||||
|
@ -2706,6 +2709,7 @@ phutil_register_library_map(array(
|
|||
1 => 'PhabricatorPolicyInterface',
|
||||
),
|
||||
'PhabricatorAuthProviderConfigController' => 'PhabricatorAuthController',
|
||||
'PhabricatorAuthProviderConfigEditor' => 'PhabricatorApplicationTransactionEditor',
|
||||
'PhabricatorAuthProviderConfigQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||
'PhabricatorAuthProviderConfigSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||
'PhabricatorAuthProviderConfigTransaction' => 'PhabricatorApplicationTransaction',
|
||||
|
|
|
@ -38,9 +38,12 @@ final class PhabricatorApplicationAuth extends PhabricatorApplication {
|
|||
'/auth/' => array(
|
||||
/*
|
||||
|
||||
'(query/(?P<key>[^/]+)/)?' =>
|
||||
'PhabricatorAuthListController',
|
||||
'config/new/' => 'PhabricatorAuthNewController',
|
||||
'(query/(?P<key>[^/]+)/)?' => 'PhabricatorAuthListController',
|
||||
'config/' => array(
|
||||
'new/' => 'PhabricatorAuthNewController',
|
||||
'new/(?P<className>[^/]+)/' => 'PhabricatorAuthEditController',
|
||||
'edit/(?P<id>\d+)/' => 'PhabricatorAuthEditController',
|
||||
),
|
||||
|
||||
*/
|
||||
'login/(?P<pkey>[^/]+)/' => 'PhabricatorAuthLoginController',
|
||||
|
|
|
@ -0,0 +1,220 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorAuthEditController
|
||||
extends PhabricatorAuthProviderConfigController {
|
||||
|
||||
private $providerClass;
|
||||
private $configID;
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$this->providerClass = idx($data, 'className');
|
||||
$this->configID = idx($data, 'id');
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
$request = $this->getRequest();
|
||||
$viewer = $request->getUser();
|
||||
|
||||
$provider = null;
|
||||
if ($this->configID) {
|
||||
$config = id(new PhabricatorAuthProviderConfigQuery())
|
||||
->setViewer($viewer)
|
||||
->requireCapabilities(
|
||||
array(
|
||||
PhabricatorPolicyCapability::CAN_VIEW,
|
||||
PhabricatorPolicyCapability::CAN_EDIT,
|
||||
))
|
||||
->withIDs(array($this->configID))
|
||||
->executeOne();
|
||||
if (!$config) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
$is_new = false;
|
||||
} else {
|
||||
$providers = PhabricatorAuthProvider::getAllBaseProviders();
|
||||
foreach ($providers as $candidate_provider) {
|
||||
if (get_class($candidate_provider) === $this->providerClass) {
|
||||
$provider = $candidate_provider;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$provider) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
// TODO: When we have multi-auth providers, support them here.
|
||||
|
||||
$configs = id(new PhabricatorAuthProviderConfigQuery())
|
||||
->setViewer($viewer)
|
||||
->withProviderClasses(array(get_class($provider)))
|
||||
->execute();
|
||||
|
||||
if ($configs) {
|
||||
// TODO: We could link to the other config's edit interface here.
|
||||
throw new Exception("This provider is already configured!");
|
||||
}
|
||||
|
||||
$config = id(new PhabricatorAuthProviderConfig())
|
||||
->setProviderClass(get_class($provider))
|
||||
->setShouldAllowLogin(1)
|
||||
->setShouldAllowRegistration(1)
|
||||
->setShouldAllowLink(1)
|
||||
->setShouldAllowUnlink(1);
|
||||
|
||||
$is_new = true;
|
||||
}
|
||||
|
||||
$errors = array();
|
||||
|
||||
$v_registration = $config->getShouldAllowRegistration();
|
||||
$v_link = $config->getShouldAllowLink();
|
||||
$v_unlink = $config->getShouldAllowUnlink();
|
||||
|
||||
if ($request->isFormPost()) {
|
||||
$xactions = array();
|
||||
|
||||
if ($is_new) {
|
||||
$xactions[] = id(new PhabricatorAuthProviderConfigTransaction())
|
||||
->setTransactionType(
|
||||
PhabricatorAuthProviderConfigTransaction::TYPE_ENABLE)
|
||||
->setNewValue(1);
|
||||
|
||||
$config->setProviderType($provider->getProviderType());
|
||||
$config->setProviderDomain($provider->getProviderDomain());
|
||||
}
|
||||
|
||||
$xactions[] = id(new PhabricatorAuthProviderConfigTransaction())
|
||||
->setTransactionType(
|
||||
PhabricatorAuthProviderConfigTransaction::TYPE_REGISTRATION)
|
||||
->setNewValue($request->getInt('allowRegistration'));
|
||||
|
||||
$xactions[] = id(new PhabricatorAuthProviderConfigTransaction())
|
||||
->setTransactionType(
|
||||
PhabricatorAuthProviderConfigTransaction::TYPE_LINK)
|
||||
->setNewValue($request->getInt('allowLink'));
|
||||
|
||||
$xactions[] = id(new PhabricatorAuthProviderConfigTransaction())
|
||||
->setTransactionType(
|
||||
PhabricatorAuthProviderConfigTransaction::TYPE_UNLINK)
|
||||
->setNewValue($request->getInt('allowUnlink'));
|
||||
|
||||
if (!$errors) {
|
||||
$editor = id(new PhabricatorAuthProviderConfigEditor())
|
||||
->setActor($viewer)
|
||||
->setContentSourceFromRequest($request)
|
||||
->setContinueOnNoEffect(true)
|
||||
->applyTransactions($config, $xactions);
|
||||
|
||||
return id(new AphrontRedirectResponse())->setURI(
|
||||
$this->getApplicationURI());
|
||||
}
|
||||
}
|
||||
|
||||
if ($errors) {
|
||||
$errors = id(new AphrontErrorView())->setErrors($errors);
|
||||
}
|
||||
|
||||
if ($is_new) {
|
||||
$button = pht('Add Provider');
|
||||
$crumb = pht('Add Provider');
|
||||
$title = pht('Add Authentication Provider');
|
||||
$cancel_uri = $this->getApplicationURI('/config/new/');
|
||||
} else {
|
||||
$button = pht('Save');
|
||||
$crumb = pht('Edit Provider');
|
||||
$title = pht('Edit Authentication Provider');
|
||||
$cancel_uri = $this->getApplicationURI();
|
||||
}
|
||||
|
||||
$str_registration = hsprintf(
|
||||
'<strong>%s:</strong> %s',
|
||||
pht('Allow Registration'),
|
||||
pht(
|
||||
'Allow users to register new Phabricator accounts using this '.
|
||||
'provider. If you disable registration, users can still use this '.
|
||||
'provider to log in to existing accounts, but will not be able to '.
|
||||
'create new accounts.'));
|
||||
|
||||
$str_link = hsprintf(
|
||||
'<strong>%s:</strong> %s',
|
||||
pht('Allow Linking Accounts'),
|
||||
pht(
|
||||
'Allow users to link account credentials for this provider to '.
|
||||
'existing Phabricator accounts. There is normally no reason to '.
|
||||
'disable this unless you are trying to move away from a provider '.
|
||||
'and want to stop users from creating new account links.'));
|
||||
|
||||
$str_unlink = hsprintf(
|
||||
'<strong>%s:</strong> %s',
|
||||
pht('Allow Unlinking Accounts'),
|
||||
pht(
|
||||
'Allow users to unlink account credentials for this provider from '.
|
||||
'existing Phabricator accounts. If you disable this, Phabricator '.
|
||||
'accounts will be permanently bound to provider accounts.'));
|
||||
|
||||
$form = id(new AphrontFormView())
|
||||
->setUser($viewer)
|
||||
->setFlexible(true)
|
||||
->appendChild(
|
||||
id(new AphrontFormStaticControl())
|
||||
->setLabel(pht('Provider'))
|
||||
->setValue($provider->getProviderName()))
|
||||
->appendChild(
|
||||
id(new AphrontFormCheckboxControl())
|
||||
->setLabel(pht('Allow'))
|
||||
->addCheckbox(
|
||||
'allowRegistration',
|
||||
1,
|
||||
$str_registration,
|
||||
$v_registration))
|
||||
->appendChild(
|
||||
id(new AphrontFormCheckboxControl())
|
||||
->addCheckbox(
|
||||
'allowLink',
|
||||
1,
|
||||
$str_link,
|
||||
$v_link))
|
||||
->appendChild(
|
||||
id(new AphrontFormCheckboxControl())
|
||||
->addCheckbox(
|
||||
'allowUnlink',
|
||||
1,
|
||||
$str_unlink,
|
||||
$v_unlink));
|
||||
|
||||
$provider->extendEditForm($form);
|
||||
|
||||
$form
|
||||
->appendChild(
|
||||
id(new AphrontFormSubmitControl())
|
||||
->addCancelButton($cancel_uri)
|
||||
->setValue($button));
|
||||
|
||||
$crumbs = $this->buildApplicationCrumbs();
|
||||
$crumbs->addCrumb(
|
||||
id(new PhabricatorCrumbView())
|
||||
->setName($crumb));
|
||||
|
||||
$xaction_view = null;
|
||||
if (!$is_new) {
|
||||
$xactions = id(new PhabricatorAuthProviderConfigTransactionQuery());
|
||||
// TOOD: ...
|
||||
}
|
||||
|
||||
return $this->buildApplicationPage(
|
||||
array(
|
||||
$crumbs,
|
||||
$errors,
|
||||
$form,
|
||||
$xaction_view
|
||||
),
|
||||
array(
|
||||
'title' => $title,
|
||||
'dust' => true,
|
||||
'device' => true,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
|
@ -26,7 +26,14 @@ final class PhabricatorAuthListController
|
|||
|
||||
$list = new PhabricatorObjectItemListView();
|
||||
foreach ($configs as $config) {
|
||||
$item = new PHUIListItemView();
|
||||
$item = new PhabricatorObjectItemView();
|
||||
|
||||
$edit_uri = $this->getApplicationURI('config/edit/'.$config->getID().'/');
|
||||
|
||||
// TODO: Needs to be built out.
|
||||
$item
|
||||
->setHeader($config->getProviderType())
|
||||
->setHref($edit_uri);
|
||||
|
||||
$list->addItem($item);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,94 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorAuthProviderConfigEditor
|
||||
extends PhabricatorApplicationTransactionEditor {
|
||||
|
||||
public function getTransactionTypes() {
|
||||
$types = parent::getTransactionTypes();
|
||||
|
||||
$types[] = PhabricatorAuthProviderConfigTransaction::TYPE_ENABLE;
|
||||
$types[] = PhabricatorAuthProviderConfigTransaction::TYPE_REGISTRATION;
|
||||
$types[] = PhabricatorAuthProviderConfigTransaction::TYPE_LINK;
|
||||
$types[] = PhabricatorAuthProviderConfigTransaction::TYPE_UNLINK;
|
||||
$types[] = PhabricatorAuthProviderConfigTransaction::TYPE_PROPERTY;
|
||||
|
||||
return $types;
|
||||
}
|
||||
|
||||
protected function getCustomTransactionOldValue(
|
||||
PhabricatorLiskDAO $object,
|
||||
PhabricatorApplicationTransaction $xaction) {
|
||||
|
||||
switch ($xaction->getTransactionType()) {
|
||||
case PhabricatorAuthProviderConfigTransaction::TYPE_ENABLE:
|
||||
return $object->getIsEnabled();
|
||||
case PhabricatorAuthProviderConfigTransaction::TYPE_REGISTRATION:
|
||||
return $object->getShouldAllowRegistration();
|
||||
case PhabricatorAuthProviderConfigTransaction::TYPE_LINK:
|
||||
return $object->getShouldAllowLink();
|
||||
case PhabricatorAuthProviderConfigTransaction::TYPE_UNLINK:
|
||||
return $object->getShouldAllowUnlink();
|
||||
case PhabricatorAuthProviderConfigTransaction::TYPE_PROPERTY:
|
||||
// TODO
|
||||
throw new Exception("TODO");
|
||||
}
|
||||
}
|
||||
|
||||
protected function getCustomTransactionNewValue(
|
||||
PhabricatorLiskDAO $object,
|
||||
PhabricatorApplicationTransaction $xaction) {
|
||||
|
||||
switch ($xaction->getTransactionType()) {
|
||||
case PhabricatorAuthProviderConfigTransaction::TYPE_ENABLE:
|
||||
case PhabricatorAuthProviderConfigTransaction::TYPE_REGISTRATION:
|
||||
case PhabricatorAuthProviderConfigTransaction::TYPE_LINK:
|
||||
case PhabricatorAuthProviderConfigTransaction::TYPE_UNLINK:
|
||||
case PhabricatorAuthProviderConfigTransaction::TYPE_PROPERTY:
|
||||
return $xaction->getNewValue();
|
||||
}
|
||||
}
|
||||
|
||||
protected function applyCustomInternalTransaction(
|
||||
PhabricatorLiskDAO $object,
|
||||
PhabricatorApplicationTransaction $xaction) {
|
||||
|
||||
$v = $xaction->getNewValue();
|
||||
switch ($xaction->getTransactionType()) {
|
||||
case PhabricatorAuthProviderConfigTransaction::TYPE_ENABLE:
|
||||
return $object->setIsEnabled($v);
|
||||
case PhabricatorAuthProviderConfigTransaction::TYPE_REGISTRATION:
|
||||
return $object->setShouldAllowRegistration($v);
|
||||
case PhabricatorAuthProviderConfigTransaction::TYPE_LINK:
|
||||
return $object->setShouldAllowLink($v);
|
||||
case PhabricatorAuthProviderConfigTransaction::TYPE_UNLINK:
|
||||
return $object->setShouldAllowUnlink($v);
|
||||
case PhabricatorAuthProviderConfigTransaction::TYPE_PROPERTY:
|
||||
// TODO
|
||||
throw new Exception("TODO");
|
||||
}
|
||||
}
|
||||
|
||||
protected function applyCustomExternalTransaction(
|
||||
PhabricatorLiskDAO $object,
|
||||
PhabricatorApplicationTransaction $xaction) {
|
||||
return;
|
||||
}
|
||||
|
||||
protected function mergeTransactions(
|
||||
PhabricatorApplicationTransaction $u,
|
||||
PhabricatorApplicationTransaction $v) {
|
||||
|
||||
$type = $u->getTransactionType();
|
||||
switch ($type) {
|
||||
case PhabricatorAuthProviderConfigTransaction::TYPE_ENABLE:
|
||||
case PhabricatorAuthProviderConfigTransaction::TYPE_REGISTRATION:
|
||||
case PhabricatorAuthProviderConfigTransaction::TYPE_LINK:
|
||||
case PhabricatorAuthProviderConfigTransaction::TYPE_UNLINK:
|
||||
// For these types, last transaction wins.
|
||||
return $v;
|
||||
}
|
||||
|
||||
return parent::mergeTransactions($u, $v);
|
||||
}
|
||||
|
||||
}
|
|
@ -110,6 +110,11 @@ abstract class PhabricatorAuthProvider {
|
|||
throw new Exception("Not implemented!");
|
||||
}
|
||||
|
||||
public function extendEditForm(AphrontFormView $form) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function createProviders() {
|
||||
return array($this);
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ abstract class PhabricatorAuthProviderOAuth extends PhabricatorAuthProvider {
|
|||
abstract protected function getOAuthClientSecret();
|
||||
abstract protected function newOAuthAdapter();
|
||||
|
||||
|
||||
public function getDescriptionForCreate() {
|
||||
return pht('Configure %s OAuth.', $this->getProviderName());
|
||||
}
|
||||
|
@ -171,4 +170,35 @@ abstract class PhabricatorAuthProviderOAuth extends PhabricatorAuthProvider {
|
|||
return array($this->loadOrCreateAccount($account_id), $response);
|
||||
}
|
||||
|
||||
public function extendEditForm(
|
||||
AphrontFormView $form) {
|
||||
|
||||
$v_id = $this->getOAuthClientID();
|
||||
|
||||
$secret = $this->getOAuthClientSecret();
|
||||
if ($secret) {
|
||||
$v_secret = str_repeat('*', strlen($secret->openEnvelope()));
|
||||
} else {
|
||||
$v_secret = '';
|
||||
}
|
||||
|
||||
$e_id = strlen($v_id) ? null : true;
|
||||
$e_secret = strlen($v_secret) ? null : true;
|
||||
|
||||
$form
|
||||
->appendChild(
|
||||
id(new AphrontFormTextControl())
|
||||
->setLabel(pht('OAuth App ID'))
|
||||
->setName('oauth:app:id')
|
||||
->setValue($v_id)
|
||||
->setError($e_id))
|
||||
->appendChild(
|
||||
id(new AphrontFormPasswordControl())
|
||||
->setLabel(pht('OAuth App Secret'))
|
||||
->setName('oauth:app:secret')
|
||||
->setValue($v_secret)
|
||||
->setError($e_secret));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ final class PhabricatorAuthProviderConfigQuery
|
|||
|
||||
private $ids;
|
||||
private $phids;
|
||||
private $providerClasses;
|
||||
|
||||
const STATUS_ALL = 'status:all';
|
||||
const STATUS_ENABLED = 'status:enabled';
|
||||
|
@ -26,6 +27,11 @@ final class PhabricatorAuthProviderConfigQuery
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function withProviderClasses(array $classes) {
|
||||
$this->providerClasses = $classes;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public static function getStatusOptions() {
|
||||
return array(
|
||||
self::STATUS_ALL => pht('All Providers'),
|
||||
|
@ -65,6 +71,13 @@ final class PhabricatorAuthProviderConfigQuery
|
|||
$this->phids);
|
||||
}
|
||||
|
||||
if ($this->providerClasses) {
|
||||
$where[] = qsprintf(
|
||||
$conn_r,
|
||||
'providerClass IN (%Ls)',
|
||||
$this->providerClasses);
|
||||
}
|
||||
|
||||
$status = $this->status;
|
||||
switch ($status) {
|
||||
case self::STATUS_ALL:
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
final class PhabricatorAuthProviderConfig extends PhabricatorAuthDAO
|
||||
implements PhabricatorPolicyInterface {
|
||||
|
||||
protected $phid;
|
||||
protected $providerClass;
|
||||
protected $providerType;
|
||||
protected $providerDomain;
|
||||
|
@ -23,6 +22,7 @@ final class PhabricatorAuthProviderConfig extends PhabricatorAuthDAO
|
|||
|
||||
public function getConfiguration() {
|
||||
return array(
|
||||
self::CONFIG_AUX_PHID => true,
|
||||
self::CONFIG_SERIALIZATION => array(
|
||||
'properties' => self::SERIALIZATION_JSON,
|
||||
),
|
||||
|
|
|
@ -3,6 +3,12 @@
|
|||
final class PhabricatorAuthProviderConfigTransaction
|
||||
extends PhabricatorApplicationTransaction {
|
||||
|
||||
const TYPE_ENABLE = 'config:enable';
|
||||
const TYPE_REGISTRATION = 'config:registration';
|
||||
const TYPE_LINK = 'config:link';
|
||||
const TYPE_UNLINK = 'config:unlink';
|
||||
const TYPE_PROPERTY = 'config:property';
|
||||
|
||||
public function getApplicationName() {
|
||||
return 'auth';
|
||||
}
|
||||
|
|
|
@ -178,8 +178,7 @@ table.aphront-form-control-checkbox-layout {
|
|||
font-size: 13px;
|
||||
}
|
||||
|
||||
table.aphront-form-control-radio-layout th,
|
||||
table.aphront-form-control-checkbox-layout th {
|
||||
table.aphront-form-control-radio-layout th {
|
||||
padding-top: 3px;
|
||||
padding-left: 8px;
|
||||
padding-bottom: 12px;
|
||||
|
@ -187,6 +186,14 @@ table.aphront-form-control-checkbox-layout th {
|
|||
color: #222222;
|
||||
}
|
||||
|
||||
table.aphront-form-control-checkbox-layout th {
|
||||
padding-top: 2px;
|
||||
padding-left: 8px;
|
||||
padding-bottom: 12px;
|
||||
color: #222222;
|
||||
}
|
||||
|
||||
|
||||
.aphront-form-control-radio-layout td input,
|
||||
.aphront-form-control-checkbox-layout td input {
|
||||
margin-top: 4px;
|
||||
|
|
Loading…
Reference in a new issue