[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/oauthserver/storage/ -> PhabricatorOAuthClientAuthorization.php (source)

   1  <?php
   2  
   3  final class PhabricatorOAuthClientAuthorization
   4    extends PhabricatorOAuthServerDAO
   5    implements PhabricatorPolicyInterface {
   6  
   7    protected $userPHID;
   8    protected $clientPHID;
   9    protected $scope;
  10  
  11    private $client = self::ATTACHABLE;
  12  
  13    public function getScopeString() {
  14      $scope = $this->getScope();
  15      $scopes = array_keys($scope);
  16      sort($scopes);
  17      return implode(' ', $scopes);
  18    }
  19  
  20    public function getConfiguration() {
  21      return array(
  22        self::CONFIG_AUX_PHID => true,
  23        self::CONFIG_SERIALIZATION => array(
  24          'scope' => self::SERIALIZATION_JSON,
  25        ),
  26        self::CONFIG_COLUMN_SCHEMA => array(
  27          'scope' => 'text',
  28        ),
  29        self::CONFIG_KEY_SCHEMA => array(
  30          'key_phid' => null,
  31          'phid' => array(
  32            'columns' => array('phid'),
  33            'unique' => true,
  34          ),
  35          'userPHID' => array(
  36            'columns' => array('userPHID', 'clientPHID'),
  37            'unique' => true,
  38          ),
  39        ),
  40      ) + parent::getConfiguration();
  41    }
  42  
  43    public function generatePHID() {
  44      return PhabricatorPHID::generateNewPHID(
  45        PhabricatorOAuthServerClientAuthorizationPHIDType::TYPECONST);
  46    }
  47  
  48    public function getClient() {
  49      return $this->assertAttached($this->client);
  50    }
  51  
  52    public function attachClient(PhabricatorOAuthServerClient $client) {
  53      $this->client = $client;
  54      return $this;
  55    }
  56  
  57  /* -(  PhabricatorPolicyInterface  )----------------------------------------- */
  58  
  59  
  60    public function getCapabilities() {
  61      return array(
  62        PhabricatorPolicyCapability::CAN_VIEW,
  63      );
  64    }
  65  
  66    public function getPolicy($capability) {
  67      switch ($capability) {
  68        case PhabricatorPolicyCapability::CAN_VIEW:
  69          return PhabricatorPolicies::POLICY_NOONE;
  70      }
  71    }
  72  
  73    public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
  74      return ($viewer->getPHID() == $this->getUserPHID());
  75    }
  76  
  77    public function describeAutomaticCapability($capability) {
  78      return pht('Authorizations can only be viewed by the authorizing user.');
  79    }
  80  
  81  }


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