Differential D15620 Diff 37653 src/applications/oauthserver/storage/PhabricatorOAuthServerClient.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/oauthserver/storage/PhabricatorOAuthServerClient.php
<?php | <?php | ||||
final class PhabricatorOAuthServerClient | final class PhabricatorOAuthServerClient | ||||
extends PhabricatorOAuthServerDAO | extends PhabricatorOAuthServerDAO | ||||
implements | implements | ||||
PhabricatorPolicyInterface, | PhabricatorPolicyInterface, | ||||
PhabricatorApplicationTransactionInterface, | PhabricatorApplicationTransactionInterface, | ||||
PhabricatorDestructibleInterface { | PhabricatorDestructibleInterface { | ||||
protected $secret; | protected $secret; | ||||
protected $name; | protected $name; | ||||
protected $redirectURI; | protected $redirectURI; | ||||
protected $creatorPHID; | protected $creatorPHID; | ||||
protected $isTrusted = 0; | protected $isTrusted; | ||||
protected $viewPolicy; | protected $viewPolicy; | ||||
protected $editPolicy; | protected $editPolicy; | ||||
protected $isDisabled; | |||||
public function getEditURI() { | public function getEditURI() { | ||||
$id = $this->getID(); | $id = $this->getID(); | ||||
return "/oauthserver/edit/{$id}/"; | return "/oauthserver/edit/{$id}/"; | ||||
} | } | ||||
public function getViewURI() { | public function getViewURI() { | ||||
$id = $this->getID(); | $id = $this->getID(); | ||||
return "/oauthserver/client/view/{$id}/"; | return "/oauthserver/client/view/{$id}/"; | ||||
} | } | ||||
public function getDeleteURI() { | |||||
$id = $this->getID(); | |||||
return "/oauthserver/client/delete/{$id}/"; | |||||
} | |||||
public static function initializeNewClient(PhabricatorUser $actor) { | public static function initializeNewClient(PhabricatorUser $actor) { | ||||
return id(new PhabricatorOAuthServerClient()) | return id(new PhabricatorOAuthServerClient()) | ||||
->setCreatorPHID($actor->getPHID()) | ->setCreatorPHID($actor->getPHID()) | ||||
->setSecret(Filesystem::readRandomCharacters(32)) | ->setSecret(Filesystem::readRandomCharacters(32)) | ||||
->setViewPolicy(PhabricatorPolicies::POLICY_USER) | ->setViewPolicy(PhabricatorPolicies::POLICY_USER) | ||||
->setEditPolicy($actor->getPHID()); | ->setEditPolicy($actor->getPHID()) | ||||
->setIsDisabled(0) | |||||
->setIsTrusted(0); | |||||
} | } | ||||
protected function getConfiguration() { | protected function getConfiguration() { | ||||
return array( | return array( | ||||
self::CONFIG_AUX_PHID => true, | self::CONFIG_AUX_PHID => true, | ||||
self::CONFIG_COLUMN_SCHEMA => array( | self::CONFIG_COLUMN_SCHEMA => array( | ||||
'name' => 'text255', | 'name' => 'text255', | ||||
'secret' => 'text32', | 'secret' => 'text32', | ||||
'redirectURI' => 'text255', | 'redirectURI' => 'text255', | ||||
'isTrusted' => 'bool', | 'isTrusted' => 'bool', | ||||
'isDisabled' => 'bool', | |||||
), | ), | ||||
self::CONFIG_KEY_SCHEMA => array( | self::CONFIG_KEY_SCHEMA => array( | ||||
'key_phid' => null, | |||||
'phid' => array( | |||||
'columns' => array('phid'), | |||||
'unique' => true, | |||||
), | |||||
'creatorPHID' => array( | 'creatorPHID' => array( | ||||
'columns' => array('creatorPHID'), | 'columns' => array('creatorPHID'), | ||||
), | ), | ||||
), | ), | ||||
) + parent::getConfiguration(); | ) + parent::getConfiguration(); | ||||
} | } | ||||
public function generatePHID() { | public function generatePHID() { | ||||
▲ Show 20 Lines • Show All 86 Lines • Show Last 20 Lines |