Path: blob/master/src/applications/oauthserver/storage/PhabricatorOAuthClientAuthorization.php
12242 views
<?php12final class PhabricatorOAuthClientAuthorization3extends PhabricatorOAuthServerDAO4implements PhabricatorPolicyInterface {56protected $userPHID;7protected $clientPHID;8protected $scope;910private $client = self::ATTACHABLE;1112public function getScopeString() {13$scope = $this->getScope();14$scopes = array_keys($scope);15sort($scopes);16return implode(' ', $scopes);17}1819protected function getConfiguration() {20return array(21self::CONFIG_AUX_PHID => true,22self::CONFIG_SERIALIZATION => array(23'scope' => self::SERIALIZATION_JSON,24),25self::CONFIG_COLUMN_SCHEMA => array(26'scope' => 'text',27),28self::CONFIG_KEY_SCHEMA => array(29'key_phid' => null,30'phid' => array(31'columns' => array('phid'),32'unique' => true,33),34'userPHID' => array(35'columns' => array('userPHID', 'clientPHID'),36'unique' => true,37),38),39) + parent::getConfiguration();40}4142public function generatePHID() {43return PhabricatorPHID::generateNewPHID(44PhabricatorOAuthServerClientAuthorizationPHIDType::TYPECONST);45}4647public function getClient() {48return $this->assertAttached($this->client);49}5051public function attachClient(PhabricatorOAuthServerClient $client) {52$this->client = $client;53return $this;54}5556/* -( PhabricatorPolicyInterface )----------------------------------------- */575859public function getCapabilities() {60return array(61PhabricatorPolicyCapability::CAN_VIEW,62);63}6465public function getPolicy($capability) {66switch ($capability) {67case PhabricatorPolicyCapability::CAN_VIEW:68return PhabricatorPolicies::POLICY_NOONE;69}70}7172public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {73return ($viewer->getPHID() == $this->getUserPHID());74}7576public function describeAutomaticCapability($capability) {77return pht('Authorizations can only be viewed by the authorizing user.');78}7980}818283