2013-06-17 19:48:41 +02:00
|
|
|
<?php
|
|
|
|
|
2013-06-17 19:49:18 +02:00
|
|
|
final class PhabricatorAuthProviderConfig extends PhabricatorAuthDAO
|
|
|
|
implements PhabricatorPolicyInterface {
|
2013-06-17 19:48:41 +02:00
|
|
|
|
|
|
|
protected $providerClass;
|
|
|
|
protected $providerType;
|
|
|
|
protected $providerDomain;
|
|
|
|
|
2013-06-17 19:53:29 +02:00
|
|
|
protected $isEnabled;
|
2013-06-17 19:48:41 +02:00
|
|
|
protected $shouldAllowLogin = 0;
|
|
|
|
protected $shouldAllowRegistration = 0;
|
|
|
|
protected $shouldAllowLink = 0;
|
|
|
|
protected $shouldAllowUnlink = 0;
|
|
|
|
|
|
|
|
protected $properties = array();
|
|
|
|
|
2013-06-17 19:53:29 +02:00
|
|
|
private $provider;
|
|
|
|
|
2013-06-17 19:48:41 +02:00
|
|
|
public function generatePHID() {
|
|
|
|
return PhabricatorPHID::generateNewPHID(
|
|
|
|
PhabricatorPHIDConstants::PHID_TYPE_AUTH);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getConfiguration() {
|
|
|
|
return array(
|
2013-06-17 19:52:38 +02:00
|
|
|
self::CONFIG_AUX_PHID => true,
|
2013-06-17 19:48:41 +02:00
|
|
|
self::CONFIG_SERIALIZATION => array(
|
|
|
|
'properties' => self::SERIALIZATION_JSON,
|
|
|
|
),
|
|
|
|
) + parent::getConfiguration();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getProperty($key, $default = null) {
|
|
|
|
return idx($this->properties, $key, $default);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setProperty($key, $value) {
|
|
|
|
$this->properties[$key] = $value;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-06-17 19:53:29 +02:00
|
|
|
public function getProvider() {
|
|
|
|
if (!$this->provider) {
|
|
|
|
$base = PhabricatorAuthProvider::getAllBaseProviders();
|
|
|
|
$found = null;
|
|
|
|
foreach ($base as $provider) {
|
|
|
|
if (get_class($provider) == $this->providerClass) {
|
|
|
|
$found = $provider;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($found) {
|
|
|
|
$this->provider = id(clone $found)->attachProviderConfig($this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $this->provider;
|
|
|
|
}
|
|
|
|
|
2013-06-17 19:48:41 +02:00
|
|
|
|
2013-06-17 19:49:18 +02:00
|
|
|
/* -( PhabricatorPolicyInterface )----------------------------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
public function getCapabilities() {
|
|
|
|
return array(
|
|
|
|
PhabricatorPolicyCapability::CAN_VIEW,
|
|
|
|
PhabricatorPolicyCapability::CAN_EDIT,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPolicy($capability) {
|
|
|
|
switch ($capability) {
|
|
|
|
case PhabricatorPolicyCapability::CAN_VIEW:
|
|
|
|
return PhabricatorPolicies::POLICY_USER;
|
|
|
|
case PhabricatorPolicyCapability::CAN_EDIT:
|
|
|
|
return PhabricatorPolicies::POLICY_ADMIN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-09-27 17:43:41 +02:00
|
|
|
public function describeAutomaticCapability($capability) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2013-06-17 19:48:41 +02:00
|
|
|
}
|