diff --git a/src/applications/oauthserver/phid/PhabricatorOAuthServerClientPHIDType.php b/src/applications/oauthserver/phid/PhabricatorOAuthServerClientPHIDType.php index a4d8834b96..4d3d64738b 100644 --- a/src/applications/oauthserver/phid/PhabricatorOAuthServerClientPHIDType.php +++ b/src/applications/oauthserver/phid/PhabricatorOAuthServerClientPHIDType.php @@ -1,39 +1,41 @@ withPHIDs($phids); } public function loadHandles( PhabricatorHandleQuery $query, array $handles, array $objects) { foreach ($handles as $phid => $handle) { $client = $objects[$phid]; - $handle->setName($client->getName()); + $handle + ->setName($client->getName()) + ->setURI($client->getURI()); } } } diff --git a/src/applications/oauthserver/storage/PhabricatorOAuthServerClient.php b/src/applications/oauthserver/storage/PhabricatorOAuthServerClient.php index a951bf5781..471433ad4b 100644 --- a/src/applications/oauthserver/storage/PhabricatorOAuthServerClient.php +++ b/src/applications/oauthserver/storage/PhabricatorOAuthServerClient.php @@ -1,129 +1,135 @@ getID(); return "/oauthserver/edit/{$id}/"; } public function getViewURI() { $id = $this->getID(); return "/oauthserver/client/view/{$id}/"; } public static function initializeNewClient(PhabricatorUser $actor) { return id(new PhabricatorOAuthServerClient()) ->setCreatorPHID($actor->getPHID()) ->setSecret(Filesystem::readRandomCharacters(32)) ->setViewPolicy(PhabricatorPolicies::POLICY_USER) ->setEditPolicy($actor->getPHID()) ->setIsDisabled(0) ->setIsTrusted(0); } protected function getConfiguration() { return array( self::CONFIG_AUX_PHID => true, self::CONFIG_COLUMN_SCHEMA => array( 'name' => 'text255', 'secret' => 'text32', 'redirectURI' => 'text255', 'isTrusted' => 'bool', 'isDisabled' => 'bool', ), self::CONFIG_KEY_SCHEMA => array( 'creatorPHID' => array( 'columns' => array('creatorPHID'), ), ), ) + parent::getConfiguration(); } public function generatePHID() { return PhabricatorPHID::generateNewPHID( PhabricatorOAuthServerClientPHIDType::TYPECONST); } + public function getURI() { + return urisprintf( + '/oauthserver/client/view/%d/', + $this->getID()); + } + /* -( PhabricatorPolicyInterface )----------------------------------------- */ public function getCapabilities() { return array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, ); } public function getPolicy($capability) { switch ($capability) { case PhabricatorPolicyCapability::CAN_VIEW: return $this->getViewPolicy(); case PhabricatorPolicyCapability::CAN_EDIT: return $this->getEditPolicy(); } } public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { return false; } /* -( PhabricatorApplicationTransactionInterface )------------------------- */ public function getApplicationTransactionEditor() { return new PhabricatorOAuthServerEditor(); } public function getApplicationTransactionTemplate() { return new PhabricatorOAuthServerTransaction(); } /* -( PhabricatorDestructibleInterface )----------------------------------- */ public function destroyObjectPermanently( PhabricatorDestructionEngine $engine) { $this->openTransaction(); $this->delete(); $authorizations = id(new PhabricatorOAuthClientAuthorization()) ->loadAllWhere('clientPHID = %s', $this->getPHID()); foreach ($authorizations as $authorization) { $authorization->delete(); } $tokens = id(new PhabricatorOAuthServerAccessToken()) ->loadAllWhere('clientPHID = %s', $this->getPHID()); foreach ($tokens as $token) { $token->delete(); } $codes = id(new PhabricatorOAuthServerAuthorizationCode()) ->loadAllWhere('clientPHID = %s', $this->getPHID()); foreach ($codes as $code) { $code->delete(); } $this->saveTransaction(); } }