Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P1865
syncProviders.php
Active
Public
Actions
Authored by
epriestley
on Oct 14 2015, 4:56 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Referenced Files
F877698: syncProviders.php
Oct 14 2015, 4:56 PM
2015-10-14 16:56:47 (UTC+0)
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
edited the content of this paste.
(Show Details)
Oct 14 2015, 4:56 PM
2015-10-14 16:56:47 (UTC+0)
epriestley
changed the title of this paste from untitled to
syncProviders.php
.
epriestley
updated the paste's language from
autodetect
to
autodetect
.
Log In to Comment