diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -2705,6 +2705,7 @@ 'PhabricatorOAuthClientEditController' => 'applications/oauthserver/controller/client/PhabricatorOAuthClientEditController.php', 'PhabricatorOAuthClientListController' => 'applications/oauthserver/controller/client/PhabricatorOAuthClientListController.php', 'PhabricatorOAuthClientSecretController' => 'applications/oauthserver/controller/client/PhabricatorOAuthClientSecretController.php', + 'PhabricatorOAuthClientTestController' => 'applications/oauthserver/controller/client/PhabricatorOAuthClientTestController.php', 'PhabricatorOAuthClientViewController' => 'applications/oauthserver/controller/client/PhabricatorOAuthClientViewController.php', 'PhabricatorOAuthResponse' => 'applications/oauthserver/PhabricatorOAuthResponse.php', 'PhabricatorOAuthServer' => 'applications/oauthserver/PhabricatorOAuthServer.php', @@ -2723,7 +2724,6 @@ 'PhabricatorOAuthServerDAO' => 'applications/oauthserver/storage/PhabricatorOAuthServerDAO.php', 'PhabricatorOAuthServerScope' => 'applications/oauthserver/PhabricatorOAuthServerScope.php', 'PhabricatorOAuthServerTestCase' => 'applications/oauthserver/__tests__/PhabricatorOAuthServerTestCase.php', - 'PhabricatorOAuthServerTestController' => 'applications/oauthserver/controller/PhabricatorOAuthServerTestController.php', 'PhabricatorOAuthServerTokenController' => 'applications/oauthserver/controller/PhabricatorOAuthServerTokenController.php', 'PhabricatorObjectHandle' => 'applications/phid/PhabricatorObjectHandle.php', 'PhabricatorObjectHasAsanaSubtaskEdgeType' => 'applications/doorkeeper/edge/PhabricatorObjectHasAsanaSubtaskEdgeType.php', @@ -7192,6 +7192,7 @@ 'PhabricatorOAuthClientEditController' => 'PhabricatorOAuthClientController', 'PhabricatorOAuthClientListController' => 'PhabricatorOAuthClientController', 'PhabricatorOAuthClientSecretController' => 'PhabricatorOAuthClientController', + 'PhabricatorOAuthClientTestController' => 'PhabricatorOAuthClientController', 'PhabricatorOAuthClientViewController' => 'PhabricatorOAuthClientController', 'PhabricatorOAuthResponse' => 'AphrontResponse', 'PhabricatorOAuthServer' => 'Phobject', @@ -7214,7 +7215,6 @@ 'PhabricatorOAuthServerDAO' => 'PhabricatorLiskDAO', 'PhabricatorOAuthServerScope' => 'Phobject', 'PhabricatorOAuthServerTestCase' => 'PhabricatorTestCase', - 'PhabricatorOAuthServerTestController' => 'PhabricatorOAuthServerController', 'PhabricatorOAuthServerTokenController' => 'PhabricatorOAuthServerController', 'PhabricatorObjectHandle' => array( 'Phobject', diff --git a/src/applications/oauthserver/application/PhabricatorOAuthServerApplication.php b/src/applications/oauthserver/application/PhabricatorOAuthServerApplication.php --- a/src/applications/oauthserver/application/PhabricatorOAuthServerApplication.php +++ b/src/applications/oauthserver/application/PhabricatorOAuthServerApplication.php @@ -50,14 +50,14 @@ '(?:query/(?P[^/]+)/)?' => 'PhabricatorOAuthClientListController', 'auth/' => 'PhabricatorOAuthServerAuthController', - 'test/(?P\d+)/' => 'PhabricatorOAuthServerTestController', 'token/' => 'PhabricatorOAuthServerTokenController', 'client/' => array( 'create/' => 'PhabricatorOAuthClientEditController', - 'delete/(?P[^/]+)/' => 'PhabricatorOAuthClientDeleteController', - 'edit/(?P[^/]+)/' => 'PhabricatorOAuthClientEditController', - 'view/(?P[^/]+)/' => 'PhabricatorOAuthClientViewController', - 'secret/(?P[^/]+)/' => 'PhabricatorOAuthClientSecretController', + 'delete/(?P\d+)/' => 'PhabricatorOAuthClientDeleteController', + 'edit/(?P\d+)/' => 'PhabricatorOAuthClientEditController', + 'view/(?P\d+)/' => 'PhabricatorOAuthClientViewController', + 'secret/(?P\d+)/' => 'PhabricatorOAuthClientSecretController', + 'test/(?P\d+)/' => 'PhabricatorOAuthClientTestController', ), ), ); diff --git a/src/applications/oauthserver/controller/PhabricatorOAuthServerAuthController.php b/src/applications/oauthserver/controller/PhabricatorOAuthServerAuthController.php --- a/src/applications/oauthserver/controller/PhabricatorOAuthServerAuthController.php +++ b/src/applications/oauthserver/controller/PhabricatorOAuthServerAuthController.php @@ -3,6 +3,12 @@ final class PhabricatorOAuthServerAuthController extends PhabricatorOAuthServerController { + protected function buildApplicationCrumbs() { + // We're specifically not putting an "OAuth Server" application crumb + // on the auth pages because it doesn't make sense to send users there. + return new PHUICrumbsView(); + } + public function handleRequest(AphrontRequest $request) { $viewer = $this->getViewer(); diff --git a/src/applications/oauthserver/controller/PhabricatorOAuthServerController.php b/src/applications/oauthserver/controller/PhabricatorOAuthServerController.php --- a/src/applications/oauthserver/controller/PhabricatorOAuthServerController.php +++ b/src/applications/oauthserver/controller/PhabricatorOAuthServerController.php @@ -5,11 +5,4 @@ const CONTEXT_AUTHORIZE = 'oauthserver.authorize'; - protected function buildApplicationCrumbs() { - // We're specifically not putting an "OAuth Server" application crumb - // on these pages because it doesn't make sense to send users there on - // the auth workflows. - return new PHUICrumbsView(); - } - } diff --git a/src/applications/oauthserver/controller/client/PhabricatorOAuthClientDeleteController.php b/src/applications/oauthserver/controller/client/PhabricatorOAuthClientDeleteController.php --- a/src/applications/oauthserver/controller/client/PhabricatorOAuthClientDeleteController.php +++ b/src/applications/oauthserver/controller/client/PhabricatorOAuthClientDeleteController.php @@ -3,13 +3,12 @@ final class PhabricatorOAuthClientDeleteController extends PhabricatorOAuthClientController { - public function processRequest() { - $request = $this->getRequest(); - $viewer = $request->getUser(); + public function handleRequest(AphrontRequest $request) { + $viewer = $this->getViewer(); $client = id(new PhabricatorOAuthServerClientQuery()) ->setViewer($viewer) - ->withPHIDs(array($this->getClientPHID())) + ->withIDs(array($request->getURIData('id'))) ->requireCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, @@ -20,14 +19,15 @@ return new Aphront404Response(); } + // TODO: This should be "disable", not "delete"! + if ($request->isFormPost()) { $client->delete(); $app_uri = $this->getApplicationURI(); return id(new AphrontRedirectResponse())->setURI($app_uri); } - $dialog = id(new AphrontDialogView()) - ->setUser($viewer) + return $this->newDialog() ->setTitle(pht('Delete OAuth Application?')) ->appendParagraph( pht( @@ -35,8 +35,6 @@ phutil_tag('strong', array(), $client->getName()))) ->addCancelButton($client->getViewURI()) ->addSubmitButton(pht('Delete Application')); - - return id(new AphrontDialogResponse())->setDialog($dialog); } } diff --git a/src/applications/oauthserver/controller/client/PhabricatorOAuthClientEditController.php b/src/applications/oauthserver/controller/client/PhabricatorOAuthClientEditController.php --- a/src/applications/oauthserver/controller/client/PhabricatorOAuthClientEditController.php +++ b/src/applications/oauthserver/controller/client/PhabricatorOAuthClientEditController.php @@ -3,15 +3,14 @@ final class PhabricatorOAuthClientEditController extends PhabricatorOAuthClientController { - public function processRequest() { - $request = $this->getRequest(); - $viewer = $request->getUser(); + public function handleRequest(AphrontRequest $request) { + $viewer = $this->getViewer(); + $id = $request->getURIData('id'); - $phid = $this->getClientPHID(); - if ($phid) { + if ($id) { $client = id(new PhabricatorOAuthServerClientQuery()) ->setViewer($viewer) - ->withPHIDs(array($phid)) + ->withIDs(array($id)) ->requireCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, @@ -124,14 +123,10 @@ ->setFormErrors($errors) ->setForm($form); - return $this->buildApplicationPage( - array( - $crumbs, - $box, - ), - array( - 'title' => $title, - )); + return $this->newPage() + ->setCrumbs($crumbs) + ->setTitle($title) + ->appendChild($box); } } diff --git a/src/applications/oauthserver/controller/client/PhabricatorOAuthClientSecretController.php b/src/applications/oauthserver/controller/client/PhabricatorOAuthClientSecretController.php --- a/src/applications/oauthserver/controller/client/PhabricatorOAuthClientSecretController.php +++ b/src/applications/oauthserver/controller/client/PhabricatorOAuthClientSecretController.php @@ -8,7 +8,7 @@ $client = id(new PhabricatorOAuthServerClientQuery()) ->setViewer($viewer) - ->withPHIDs(array($this->getClientPHID())) + ->withIDs(array($request->getURIData('id'))) ->requireCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, @@ -27,22 +27,20 @@ if ($request->isFormPost()) { $secret = $client->getSecret(); + $body = id(new PHUIFormLayoutView()) ->appendChild( id(new AphrontFormTextAreaControl()) - ->setLabel(pht('Plaintext')) - ->setReadOnly(true) - ->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_SHORT) - ->setValue($secret)); + ->setLabel(pht('Plaintext')) + ->setReadOnly(true) + ->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_SHORT) + ->setValue($secret)); - $dialog = id(new AphrontDialogView()) - ->setUser($viewer) + return $this->newDialog() ->setWidth(AphrontDialogView::WIDTH_FORM) ->setTitle(pht('Application Secret')) ->appendChild($body) ->addCancelButton($view_uri, pht('Done')); - - return id(new AphrontDialogResponse())->setDialog($dialog); } @@ -59,8 +57,8 @@ 'your monitor to create a human shield, keeping it safe from prying '. 'eyes. Protect company secrets!'); } + return $this->newDialog() - ->setUser($viewer) ->setTitle(pht('Really show application secret?')) ->appendChild($body) ->addSubmitButton(pht('Show Application Secret')) diff --git a/src/applications/oauthserver/controller/PhabricatorOAuthServerTestController.php b/src/applications/oauthserver/controller/client/PhabricatorOAuthClientTestController.php rename from src/applications/oauthserver/controller/PhabricatorOAuthServerTestController.php rename to src/applications/oauthserver/controller/client/PhabricatorOAuthClientTestController.php --- a/src/applications/oauthserver/controller/PhabricatorOAuthServerTestController.php +++ b/src/applications/oauthserver/controller/client/PhabricatorOAuthClientTestController.php @@ -1,7 +1,7 @@ getViewer(); diff --git a/src/applications/oauthserver/controller/client/PhabricatorOAuthClientViewController.php b/src/applications/oauthserver/controller/client/PhabricatorOAuthClientViewController.php --- a/src/applications/oauthserver/controller/client/PhabricatorOAuthClientViewController.php +++ b/src/applications/oauthserver/controller/client/PhabricatorOAuthClientViewController.php @@ -3,13 +3,12 @@ final class PhabricatorOAuthClientViewController extends PhabricatorOAuthClientController { - public function processRequest() { - $request = $this->getRequest(); - $viewer = $request->getUser(); + public function handleRequest(AphrontRequest $request) { + $viewer = $this->getViewer(); $client = id(new PhabricatorOAuthServerClientQuery()) ->setViewer($viewer) - ->withPHIDs(array($this->getClientPHID())) + ->withIDs(array($request->getURIData('id'))) ->executeOne(); if (!$client) { return new Aphront404Response(); @@ -27,18 +26,16 @@ ->setHeader($header) ->addPropertyList($properties); - return $this->buildApplicationPage( - array( - $crumbs, - $box, - ), - array( - 'title' => pht('OAuth Application: %s', $client->getName()), - )); + $title = pht('OAuth Application: %s', $client->getName()); + + return $this->newPage() + ->setCrumbs($crumbs) + ->setTitle($title) + ->appendChild($box); } private function buildHeaderView(PhabricatorOAuthServerClient $client) { - $viewer = $this->getRequest()->getUser(); + $viewer = $this->getViewer(); $header = id(new PHUIHeaderView()) ->setUser($viewer) @@ -49,7 +46,7 @@ } private function buildActionView(PhabricatorOAuthServerClient $client) { - $viewer = $this->getRequest()->getUser(); + $viewer = $this->getViewer(); $can_edit = PhabricatorPolicyFilter::hasCapability( $viewer, @@ -63,7 +60,6 @@ ->executeOne(); $is_authorized = (bool)$authorization; $id = $client->getID(); - $phid = $client->getPHID(); $view = id(new PhabricatorActionListView()) ->setUser($viewer); @@ -80,7 +76,7 @@ id(new PhabricatorActionView()) ->setName(pht('Show Application Secret')) ->setIcon('fa-eye') - ->setHref($this->getApplicationURI("client/secret/{$phid}/")) + ->setHref($this->getApplicationURI("client/secret/{$id}/")) ->setDisabled(!$can_edit) ->setWorkflow(true)); @@ -98,7 +94,7 @@ ->setIcon('fa-wrench') ->setWorkflow(true) ->setDisabled($is_authorized) - ->setHref($this->getApplicationURI('test/'.$id.'/'))); + ->setHref($this->getApplicationURI("client/test/{$id}/"))); return $view; } @@ -110,7 +106,7 @@ ->setUser($viewer); $view->addProperty( - pht('Client ID'), + pht('Client PHID'), $client->getPHID()); $view->addProperty( diff --git a/src/applications/oauthserver/query/PhabricatorOAuthServerClientSearchEngine.php b/src/applications/oauthserver/query/PhabricatorOAuthServerClientSearchEngine.php --- a/src/applications/oauthserver/query/PhabricatorOAuthServerClientSearchEngine.php +++ b/src/applications/oauthserver/query/PhabricatorOAuthServerClientSearchEngine.php @@ -79,12 +79,6 @@ return parent::buildSavedQueryFromBuiltin($query_key); } - protected function getRequiredHandlePHIDsForResultList( - array $clients, - PhabricatorSavedQuery $query) { - return mpull($clients, 'getCreatorPHID'); - } - protected function renderResultList( array $clients, PhabricatorSavedQuery $query, @@ -96,14 +90,11 @@ $list = id(new PHUIObjectItemListView()) ->setUser($viewer); foreach ($clients as $client) { - $creator = $handles[$client->getCreatorPHID()]; - $item = id(new PHUIObjectItemView()) ->setObjectName(pht('Application %d', $client->getID())) ->setHeader($client->getName()) ->setHref($client->getViewURI()) - ->setObject($client) - ->addByline(pht('Creator: %s', $creator->renderLink())); + ->setObject($client); $list->addItem($item); } diff --git a/src/applications/oauthserver/storage/PhabricatorOAuthServerClient.php b/src/applications/oauthserver/storage/PhabricatorOAuthServerClient.php --- a/src/applications/oauthserver/storage/PhabricatorOAuthServerClient.php +++ b/src/applications/oauthserver/storage/PhabricatorOAuthServerClient.php @@ -15,15 +15,18 @@ protected $editPolicy; public function getEditURI() { - return '/oauthserver/client/edit/'.$this->getPHID().'/'; + $id = $this->getID(); + return "/oauthserver/client/edit/{$id}/"; } public function getViewURI() { - return '/oauthserver/client/view/'.$this->getPHID().'/'; + $id = $this->getID(); + return "/oauthserver/client/view/{$id}/"; } public function getDeleteURI() { - return '/oauthserver/client/delete/'.$this->getPHID().'/'; + $id = $this->getID(); + return "/oauthserver/client/delete/{$id}/"; } public static function initializeNewClient(PhabricatorUser $actor) {