[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/auth/storage/ -> PhabricatorAuthProviderConfig.php (source)

   1  <?php
   2  
   3  final class PhabricatorAuthProviderConfig extends PhabricatorAuthDAO
   4    implements PhabricatorPolicyInterface {
   5  
   6    protected $providerClass;
   7    protected $providerType;
   8    protected $providerDomain;
   9  
  10    protected $isEnabled;
  11    protected $shouldAllowLogin         = 0;
  12    protected $shouldAllowRegistration  = 0;
  13    protected $shouldAllowLink          = 0;
  14    protected $shouldAllowUnlink        = 0;
  15    protected $shouldTrustEmails        = 0;
  16  
  17    protected $properties = array();
  18  
  19    private $provider;
  20  
  21    public function generatePHID() {
  22      return PhabricatorPHID::generateNewPHID(
  23        PhabricatorPHIDConstants::PHID_TYPE_AUTH);
  24    }
  25  
  26    public function getConfiguration() {
  27      return array(
  28        self::CONFIG_AUX_PHID => true,
  29        self::CONFIG_SERIALIZATION => array(
  30          'properties' => self::SERIALIZATION_JSON,
  31        ),
  32        self::CONFIG_COLUMN_SCHEMA => array(
  33          'isEnabled' => 'bool',
  34          'providerClass' => 'text128',
  35          'providerType' => 'text32',
  36          'providerDomain' => 'text128',
  37          'shouldAllowLogin' => 'bool',
  38          'shouldAllowRegistration' => 'bool',
  39          'shouldAllowLink' => 'bool',
  40          'shouldAllowUnlink' => 'bool',
  41          'shouldTrustEmails' => 'bool',
  42        ),
  43        self::CONFIG_KEY_SCHEMA => array(
  44          'key_provider' => array(
  45            'columns' => array('providerType', 'providerDomain'),
  46            'unique' => true,
  47          ),
  48          'key_class' => array(
  49            'columns' => array('providerClass'),
  50          ),
  51        ),
  52      ) + parent::getConfiguration();
  53    }
  54  
  55    public function getProperty($key, $default = null) {
  56      return idx($this->properties, $key, $default);
  57    }
  58  
  59    public function setProperty($key, $value) {
  60      $this->properties[$key] = $value;
  61      return $this;
  62    }
  63  
  64    public function getProvider() {
  65      if (!$this->provider) {
  66        $base = PhabricatorAuthProvider::getAllBaseProviders();
  67        $found = null;
  68        foreach ($base as $provider) {
  69          if (get_class($provider) == $this->providerClass) {
  70            $found = $provider;
  71            break;
  72          }
  73        }
  74        if ($found) {
  75          $this->provider = id(clone $found)->attachProviderConfig($this);
  76        }
  77      }
  78      return $this->provider;
  79    }
  80  
  81  
  82  /* -(  PhabricatorPolicyInterface  )----------------------------------------- */
  83  
  84  
  85    public function getCapabilities() {
  86      return array(
  87        PhabricatorPolicyCapability::CAN_VIEW,
  88        PhabricatorPolicyCapability::CAN_EDIT,
  89      );
  90    }
  91  
  92    public function getPolicy($capability) {
  93      switch ($capability) {
  94        case PhabricatorPolicyCapability::CAN_VIEW:
  95          return PhabricatorPolicies::POLICY_USER;
  96        case PhabricatorPolicyCapability::CAN_EDIT:
  97          return PhabricatorPolicies::POLICY_ADMIN;
  98      }
  99    }
 100  
 101    public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
 102      return false;
 103    }
 104  
 105    public function describeAutomaticCapability($capability) {
 106      return null;
 107    }
 108  
 109  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1