@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Update Conduit for handleRequest

Summary: Ref T8628. Updates Conduit for handleRequest

Test Plan: Use Conduit, test list, method calls, try a query, post this diff.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T8628

Differential Revision: https://secure.phabricator.com/D14265

+18 -33
+6 -14
src/applications/conduit/controller/PhabricatorConduitAPIController.php
··· 7 7 return false; 8 8 } 9 9 10 - private $method; 11 - 12 - public function willProcessRequest(array $data) { 13 - $this->method = $data['method']; 14 - return $this; 15 - } 16 - 17 - public function processRequest() { 10 + public function handleRequest(AphrontRequest $request) { 11 + $method = $request->getURIData('method'); 18 12 $time_start = microtime(true); 19 - $request = $this->getRequest(); 20 - 21 - $method = $this->method; 22 13 23 14 $api_request = null; 24 15 $method_implementation = null; ··· 55 46 $conduit_username = '-'; 56 47 if ($call->shouldRequireAuthentication()) { 57 48 $metadata['scope'] = $call->getRequiredScope(); 58 - $auth_error = $this->authenticateUser($api_request, $metadata); 49 + $auth_error = $this->authenticateUser($api_request, $metadata, $method); 59 50 // If we've explicitly authenticated the user here and either done 60 51 // CSRF validation or are using a non-web authentication mechanism. 61 52 $allow_unguarded_writes = true; ··· 169 160 */ 170 161 private function authenticateUser( 171 162 ConduitAPIRequest $api_request, 172 - array $metadata) { 163 + array $metadata, 164 + $method) { 173 165 174 166 $request = $this->getRequest(); 175 167 ··· 207 199 unset($protocol_data['scope']); 208 200 209 201 ConduitClient::verifySignature( 210 - $this->method, 202 + $method, 211 203 $api_request->getAllParameters(), 212 204 $protocol_data, 213 205 $ssl_public_key);
+2 -8
src/applications/conduit/controller/PhabricatorConduitListController.php
··· 3 3 final class PhabricatorConduitListController 4 4 extends PhabricatorConduitController { 5 5 6 - private $queryKey; 7 - 8 6 public function shouldAllowPublic() { 9 7 return true; 10 8 } 11 9 12 - public function willProcessRequest(array $data) { 13 - $this->queryKey = idx($data, 'queryKey'); 14 - } 15 - 16 - public function processRequest() { 10 + public function handleRequest(AphrontRequest $request) { 17 11 $controller = id(new PhabricatorApplicationSearchController()) 18 - ->setQueryKey($this->queryKey) 12 + ->setQueryKey($request->getURIData('queryKey')) 19 13 ->setSearchEngine(new PhabricatorConduitSearchEngine()) 20 14 ->setNavigation($this->buildSideNavView()); 21 15 return $this->delegateToController($controller);
+2 -3
src/applications/conduit/controller/PhabricatorConduitLogController.php
··· 3 3 final class PhabricatorConduitLogController 4 4 extends PhabricatorConduitController { 5 5 6 - public function processRequest() { 7 - $request = $this->getRequest(); 8 - $viewer = $request->getUser(); 6 + public function handleRequest(AphrontRequest $request) { 7 + $viewer = $request->getViewer(); 9 8 10 9 $conn_table = new PhabricatorConduitConnectionLog(); 11 10 $call_table = new PhabricatorConduitMethodCallLog();
+6 -6
src/applications/conduit/controller/PhabricatorConduitTokenController.php
··· 3 3 final class PhabricatorConduitTokenController 4 4 extends PhabricatorConduitController { 5 5 6 - public function processRequest() { 7 - $user = $this->getRequest()->getUser(); 6 + public function handleRequest(AphrontRequest $request) { 7 + $viewer = $request->getViewer(); 8 8 9 9 id(new PhabricatorAuthSessionEngine())->requireHighSecuritySession( 10 - $user, 10 + $viewer, 11 11 $this->getRequest(), 12 12 '/'); 13 13 ··· 19 19 $old_token = id(new PhabricatorConduitCertificateToken()) 20 20 ->loadOneWhere( 21 21 'userPHID = %s', 22 - $user->getPHID()); 22 + $viewer->getPHID()); 23 23 if ($old_token) { 24 24 $old_token->delete(); 25 25 } 26 26 27 27 $token = id(new PhabricatorConduitCertificateToken()) 28 - ->setUserPHID($user->getPHID()) 28 + ->setUserPHID($viewer->getPHID()) 29 29 ->setToken(Filesystem::readRandomCharacters(40)) 30 30 ->save(); 31 31 ··· 42 42 Javelin::initBehavior('select-on-click'); 43 43 44 44 $form = id(new AphrontFormView()) 45 - ->setUser($user) 45 + ->setUser($viewer) 46 46 ->appendRemarkupInstructions($pre_instructions) 47 47 ->appendChild( 48 48 id(new AphrontFormTextAreaControl())
+1 -1
src/applications/conduit/controller/PhabricatorConduitTokenEditController.php
··· 5 5 6 6 public function handleRequest(AphrontRequest $request) { 7 7 $viewer = $request->getViewer(); 8 - 9 8 $id = $request->getURIData('id'); 9 + 10 10 if ($id) { 11 11 $token = id(new PhabricatorConduitTokenQuery()) 12 12 ->setViewer($viewer)
+1 -1
src/applications/conduit/controller/PhabricatorConduitTokenTerminateController.php
··· 5 5 6 6 public function handleRequest(AphrontRequest $request) { 7 7 $viewer = $request->getViewer(); 8 - 9 8 $object_phid = $request->getStr('objectPHID'); 10 9 $id = $request->getURIData('id'); 10 + 11 11 if ($id) { 12 12 $token = id(new PhabricatorConduitTokenQuery()) 13 13 ->setViewer($viewer)