Page MenuHomePhabricator
Paste P1865

syncProviders.php
ActivePublic

Authored by epriestley on Oct 14 2015, 4:56 PM.
Tags
None
Referenced Files
F877698: syncProviders.php
Oct 14 2015, 4:56 PM
Subscribers
None
...
private function syncProviders($instance) {
$viewer = $this->getViewer();
$instance_name = PhabricatorEnv::getEnvConfig('cluster.instance');
$configs = id(new PhabricatorAuthProviderConfigQuery())
->setViewer($viewer)
->execute();
if (!$configs) {
$config = id(new PhabricatorAuthProviderConfig())
->setProviderClass('PhabricatorPhabricatorAuthProvider')
->setProviderType('phabricator')
->setProviderDomain('self');
} else if (count($configs) > 1) {
throw new Exception(
pht(
'This instance ("%s") has more than one authentication provider.',
$instance_name));
} else {
$config = head($configs);
if ($config->getProviderClass() != 'PhabricatorPhabricatorAuthProvider') {
throw new Exception(
pht(
'This instance ("%s") has the wrong class of authentication '.
'provider ("%s").',
$instance_name,
$config->getProviderClass()));
}
}
$config
->setIsEnabled(1)
->setShouldAllowLogin(1)
->setShouldAllowRegistration(1)
->setShouldAllowLink(0)
->setShouldAllowUnlink(0)
->setShouldTrustEmails(1)
->setShouldAutoLogin(1)
->setProperties(
array(
PhabricatorPhabricatorAuthProvider::PROPERTY_PHABRICATOR_NAME
=> 'phacility',
PhabricatorPhabricatorAuthProvider::PROPERTY_PHABRICATOR_URI
=> PhacilityServices::getAdminURI(),
PhabricatorOAuth2AuthProvider::PROPERTY_APP_ID
=> $instance['oauth']['id'],
PhabricatorOAuth2AuthProvider::PROPERTY_APP_SECRET
=> $instance['oauth']['secret'],
))
->save();
}
...

Event Timeline

epriestley changed the title of this paste from untitled to syncProviders.php.
epriestley updated the paste's language from autodetect to autodetect.