1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-30 09:20:58 +01:00

Allow Conduit console to be browsed by logged-out users

Summary:
Ref T4830. A few methods, like `conduit.ping`, are callable without authentication, so this even has some use cases. Also:

  - Make some Differential stuff a little more consistent.
  - Use slightly more modern rendering.
  - Deprecate the status-oriented `user` calls; these will be replaced by Calendar methods.

Test Plan: Browsed console as logged out / logged in users.

Reviewers: chad, btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T4830

Differential Revision: https://secure.phabricator.com/D8826
This commit is contained in:
epriestley 2014-04-21 15:32:48 -07:00
parent 4143ecf015
commit 27d426e3fe
21 changed files with 100 additions and 118 deletions

View file

@ -2718,26 +2718,26 @@ phutil_register_library_map(array(
'ConduitAPI_conpherence_updatethread_Method' => 'ConduitAPI_conpherence_Method', 'ConduitAPI_conpherence_updatethread_Method' => 'ConduitAPI_conpherence_Method',
'ConduitAPI_differential_Method' => 'ConduitAPIMethod', 'ConduitAPI_differential_Method' => 'ConduitAPIMethod',
'ConduitAPI_differential_close_Method' => 'ConduitAPI_differential_Method', 'ConduitAPI_differential_close_Method' => 'ConduitAPI_differential_Method',
'ConduitAPI_differential_createcomment_Method' => 'ConduitAPIMethod', 'ConduitAPI_differential_createcomment_Method' => 'ConduitAPI_differential_Method',
'ConduitAPI_differential_creatediff_Method' => 'ConduitAPIMethod', 'ConduitAPI_differential_creatediff_Method' => 'ConduitAPI_differential_Method',
'ConduitAPI_differential_createinline_Method' => 'ConduitAPI_differential_Method', 'ConduitAPI_differential_createinline_Method' => 'ConduitAPI_differential_Method',
'ConduitAPI_differential_createrawdiff_Method' => 'ConduitAPI_differential_Method', 'ConduitAPI_differential_createrawdiff_Method' => 'ConduitAPI_differential_Method',
'ConduitAPI_differential_createrevision_Method' => 'ConduitAPI_differential_Method', 'ConduitAPI_differential_createrevision_Method' => 'ConduitAPI_differential_Method',
'ConduitAPI_differential_find_Method' => 'ConduitAPIMethod', 'ConduitAPI_differential_find_Method' => 'ConduitAPI_differential_Method',
'ConduitAPI_differential_finishpostponedlinters_Method' => 'ConduitAPIMethod', 'ConduitAPI_differential_finishpostponedlinters_Method' => 'ConduitAPI_differential_Method',
'ConduitAPI_differential_getalldiffs_Method' => 'ConduitAPIMethod', 'ConduitAPI_differential_getalldiffs_Method' => 'ConduitAPI_differential_Method',
'ConduitAPI_differential_getcommitmessage_Method' => 'ConduitAPIMethod', 'ConduitAPI_differential_getcommitmessage_Method' => 'ConduitAPI_differential_Method',
'ConduitAPI_differential_getcommitpaths_Method' => 'ConduitAPIMethod', 'ConduitAPI_differential_getcommitpaths_Method' => 'ConduitAPI_differential_Method',
'ConduitAPI_differential_getdiff_Method' => 'ConduitAPIMethod', 'ConduitAPI_differential_getdiff_Method' => 'ConduitAPI_differential_Method',
'ConduitAPI_differential_getrawdiff_Method' => 'ConduitAPIMethod', 'ConduitAPI_differential_getrawdiff_Method' => 'ConduitAPI_differential_Method',
'ConduitAPI_differential_getrevision_Method' => 'ConduitAPI_differential_Method', 'ConduitAPI_differential_getrevision_Method' => 'ConduitAPI_differential_Method',
'ConduitAPI_differential_getrevisioncomments_Method' => 'ConduitAPI_differential_Method', 'ConduitAPI_differential_getrevisioncomments_Method' => 'ConduitAPI_differential_Method',
'ConduitAPI_differential_parsecommitmessage_Method' => 'ConduitAPIMethod', 'ConduitAPI_differential_parsecommitmessage_Method' => 'ConduitAPI_differential_Method',
'ConduitAPI_differential_query_Method' => 'ConduitAPI_differential_Method', 'ConduitAPI_differential_query_Method' => 'ConduitAPI_differential_Method',
'ConduitAPI_differential_querydiffs_Method' => 'ConduitAPIMethod', 'ConduitAPI_differential_querydiffs_Method' => 'ConduitAPI_differential_Method',
'ConduitAPI_differential_setdiffproperty_Method' => 'ConduitAPIMethod', 'ConduitAPI_differential_setdiffproperty_Method' => 'ConduitAPI_differential_Method',
'ConduitAPI_differential_updaterevision_Method' => 'ConduitAPI_differential_Method', 'ConduitAPI_differential_updaterevision_Method' => 'ConduitAPI_differential_Method',
'ConduitAPI_differential_updateunitresults_Method' => 'ConduitAPIMethod', 'ConduitAPI_differential_updateunitresults_Method' => 'ConduitAPI_differential_Method',
'ConduitAPI_diffusion_Method' => 'ConduitAPIMethod', 'ConduitAPI_diffusion_Method' => 'ConduitAPIMethod',
'ConduitAPI_diffusion_abstractquery_Method' => 'ConduitAPI_diffusion_Method', 'ConduitAPI_diffusion_abstractquery_Method' => 'ConduitAPI_diffusion_Method',
'ConduitAPI_diffusion_branchquery_Method' => 'ConduitAPI_diffusion_abstractquery_Method', 'ConduitAPI_diffusion_branchquery_Method' => 'ConduitAPI_diffusion_abstractquery_Method',

View file

@ -1,13 +1,14 @@
<?php <?php
/**
* @group conduit
*/
final class PhabricatorConduitConsoleController final class PhabricatorConduitConsoleController
extends PhabricatorConduitController { extends PhabricatorConduitController {
private $method; private $method;
public function shouldAllowPublic() {
return true;
}
public function willProcessRequest(array $data) { public function willProcessRequest(array $data) {
$this->method = $data['method']; $this->method = $data['method'];
} }
@ -26,28 +27,25 @@ final class PhabricatorConduitConsoleController
return new Aphront404Response(); return new Aphront404Response();
} }
$can_call_method = false;
$status = $method->getMethodStatus(); $status = $method->getMethodStatus();
$reason = $method->getMethodStatusDescription(); $reason = $method->getMethodStatusDescription();
$errors = array();
$status_view = null; switch ($status) {
if ($status != ConduitAPIMethod::METHOD_STATUS_STABLE) { case ConduitAPIMethod::METHOD_STATUS_DEPRECATED:
$status_view = new AphrontErrorView(); $reason = nonempty($reason, pht('This method is deprecated.'));
switch ($status) { $errors[] = pht('Deprecated Method: %s', $reason);
case ConduitAPIMethod::METHOD_STATUS_DEPRECATED: break;
$status_view->setTitle('Deprecated Method'); case ConduitAPIMethod::METHOD_STATUS_UNSTABLE:
$status_view->appendChild( $reason = nonempty(
nonempty($reason, "This method is deprecated.")); $reason,
break; pht(
case ConduitAPIMethod::METHOD_STATUS_UNSTABLE: 'This method is new and unstable. Its interface is subject '.
$status_view->setSeverity(AphrontErrorView::SEVERITY_WARNING); 'to change.'));
$status_view->setTitle('Unstable Method'); $errors[] = pht('Unstable Method: %s', $reason);
$status_view->appendChild( break;
nonempty(
$reason,
"This method is new and unstable. Its interface is subject ".
"to change."));
break;
}
} }
$error_types = $method->defineErrorTypes(); $error_types = $method->defineErrorTypes();
@ -61,7 +59,8 @@ final class PhabricatorConduitConsoleController
} }
$error_description = phutil_tag('ul', array(), $error_description); $error_description = phutil_tag('ul', array(), $error_description);
} else { } else {
$error_description = "This method does not raise any specific errors."; $error_description = pht(
'This method does not raise any specific errors.');
} }
$form = new AphrontFormView(); $form = new AphrontFormView();
@ -95,29 +94,38 @@ final class PhabricatorConduitConsoleController
->setCaption($desc)); ->setCaption($desc));
} }
$form $must_login = !$viewer->isLoggedIn() &&
->appendChild( $method->shouldRequireAuthentication();
id(new AphrontFormSelectControl()) if ($must_login) {
->setLabel('Output Format') $errors[] = pht(
->setName('output') 'Login Required: This method requires authentication. You must '.
->setOptions( 'log in before you can make calls to it.');
array( } else {
'human' => 'Human Readable', $form
'json' => 'JSON', ->appendChild(
))) id(new AphrontFormSelectControl())
->appendChild( ->setLabel('Output Format')
id(new AphrontFormSubmitControl()) ->setName('output')
->addCancelButton($this->getApplicationURI()) ->setOptions(
->setValue('Call Method')); array(
'human' => 'Human Readable',
'json' => 'JSON',
)))
->appendChild(
id(new AphrontFormSubmitControl())
->addCancelButton($this->getApplicationURI())
->setValue(pht('Call Method')));
}
$header = id(new PHUIHeaderView())
->setUser($viewer)
->setHeader($method->getAPIMethodName());
$form_box = id(new PHUIObjectBoxView()) $form_box = id(new PHUIObjectBoxView())
->setHeaderText($method->getAPIMethodName()) ->setHeader($header)
->setFormErrors($errors)
->setForm($form); ->setForm($form);
if ($status_view) {
$form_box->setErrorView($status_view);
}
$crumbs = $this->buildApplicationCrumbs(); $crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb($method->getAPIMethodName()); $crumbs->addTextCrumb($method->getAPIMethodName());

View file

@ -1,14 +1,15 @@
<?php <?php
/**
* @group conduit
*/
final class PhabricatorConduitListController final class PhabricatorConduitListController
extends PhabricatorConduitController extends PhabricatorConduitController
implements PhabricatorApplicationSearchResultsControllerInterface { implements PhabricatorApplicationSearchResultsControllerInterface {
private $queryKey; private $queryKey;
public function shouldAllowPublic() {
return true;
}
public function willProcessRequest(array $data) { public function willProcessRequest(array $data) {
$this->queryKey = idx($data, 'queryKey'); $this->queryKey = idx($data, 'queryKey');
} }

View file

@ -1,10 +1,7 @@
<?php <?php
/**
* @group conduit
*/
final class ConduitAPI_differential_createcomment_Method final class ConduitAPI_differential_createcomment_Method
extends ConduitAPIMethod { extends ConduitAPI_differential_Method {
public function getMethodDescription() { public function getMethodDescription() {
return pht("Add a comment to a Differential revision."); return pht("Add a comment to a Differential revision.");

View file

@ -1,6 +1,7 @@
<?php <?php
final class ConduitAPI_differential_creatediff_Method extends ConduitAPIMethod { final class ConduitAPI_differential_creatediff_Method
extends ConduitAPI_differential_Method {
public function getMethodDescription() { public function getMethodDescription() {
return "Create a new Differential diff."; return "Create a new Differential diff.";

View file

@ -1,8 +1,5 @@
<?php <?php
/**
* @group conduit
*/
final class ConduitAPI_differential_createinline_Method final class ConduitAPI_differential_createinline_Method
extends ConduitAPI_differential_Method { extends ConduitAPI_differential_Method {

View file

@ -1,8 +1,5 @@
<?php <?php
/**
* @group conduit
*/
final class ConduitAPI_differential_createrawdiff_Method final class ConduitAPI_differential_createrawdiff_Method
extends ConduitAPI_differential_Method { extends ConduitAPI_differential_Method {

View file

@ -1,9 +1,7 @@
<?php <?php
/** final class ConduitAPI_differential_find_Method
* @group conduit extends ConduitAPI_differential_Method {
*/
final class ConduitAPI_differential_find_Method extends ConduitAPIMethod {
public function getMethodStatus() { public function getMethodStatus() {
return self::METHOD_STATUS_DEPRECATED; return self::METHOD_STATUS_DEPRECATED;

View file

@ -1,10 +1,7 @@
<?php <?php
/**
* @group conduit
*/
final class ConduitAPI_differential_finishpostponedlinters_Method final class ConduitAPI_differential_finishpostponedlinters_Method
extends ConduitAPIMethod { extends ConduitAPI_differential_Method {
public function getMethodDescription() { public function getMethodDescription() {
return "Update diff with new lint messages and mark postponed ". return "Update diff with new lint messages and mark postponed ".

View file

@ -1,10 +1,7 @@
<?php <?php
/**
* @group conduit
*/
final class ConduitAPI_differential_getalldiffs_Method final class ConduitAPI_differential_getalldiffs_Method
extends ConduitAPIMethod { extends ConduitAPI_differential_Method {
public function getMethodStatus() { public function getMethodStatus() {
return self::METHOD_STATUS_DEPRECATED; return self::METHOD_STATUS_DEPRECATED;

View file

@ -1,7 +1,7 @@
<?php <?php
final class ConduitAPI_differential_getcommitmessage_Method final class ConduitAPI_differential_getcommitmessage_Method
extends ConduitAPIMethod { extends ConduitAPI_differential_Method {
public function getMethodDescription() { public function getMethodDescription() {
return "Retrieve Differential commit messages or message templates."; return "Retrieve Differential commit messages or message templates.";

View file

@ -1,10 +1,7 @@
<?php <?php
/**
* @group conduit
*/
final class ConduitAPI_differential_getcommitpaths_Method final class ConduitAPI_differential_getcommitpaths_Method
extends ConduitAPIMethod { extends ConduitAPI_differential_Method {
public function getMethodDescription() { public function getMethodDescription() {
return "Query which paths should be included when committing a ". return "Query which paths should be included when committing a ".

View file

@ -1,10 +1,7 @@
<?php <?php
/**
* @group conduit
*/
final class ConduitAPI_differential_getdiff_Method final class ConduitAPI_differential_getdiff_Method
extends ConduitAPIMethod { extends ConduitAPI_differential_Method {
public function shouldAllowPublic() { public function shouldAllowPublic() {
return true; return true;

View file

@ -1,7 +1,7 @@
<?php <?php
final class ConduitAPI_differential_getrawdiff_Method final class ConduitAPI_differential_getrawdiff_Method
extends ConduitAPIMethod { extends ConduitAPI_differential_Method {
public function getMethodDescription() { public function getMethodDescription() {
return pht("Retrieve a raw diff"); return pht("Retrieve a raw diff");

View file

@ -1,7 +1,7 @@
<?php <?php
final class ConduitAPI_differential_parsecommitmessage_Method final class ConduitAPI_differential_parsecommitmessage_Method
extends ConduitAPIMethod { extends ConduitAPI_differential_Method {
private $errors; private $errors;

View file

@ -1,10 +1,7 @@
<?php <?php
/**
* @group conduit
*/
final class ConduitAPI_differential_querydiffs_Method final class ConduitAPI_differential_querydiffs_Method
extends ConduitAPIMethod { extends ConduitAPI_differential_Method {
public function getMethodDescription() { public function getMethodDescription() {
return pht('Query differential diffs which match certain criteria.'); return pht('Query differential diffs which match certain criteria.');

View file

@ -1,10 +1,7 @@
<?php <?php
/**
* @group conduit
*/
final class ConduitAPI_differential_setdiffproperty_Method final class ConduitAPI_differential_setdiffproperty_Method
extends ConduitAPIMethod { extends ConduitAPI_differential_Method {
public function getMethodDescription() { public function getMethodDescription() {
return "Attach properties to Differential diffs."; return "Attach properties to Differential diffs.";

View file

@ -1,10 +1,7 @@
<?php <?php
/**
* @group conduit
*/
final class ConduitAPI_differential_updateunitresults_Method final class ConduitAPI_differential_updateunitresults_Method
extends ConduitAPIMethod { extends ConduitAPI_differential_Method {
public function getMethodDescription() { public function getMethodDescription() {
return "Update arc unit results for a postponed test."; return "Update arc unit results for a postponed test.";

View file

@ -1,8 +1,5 @@
<?php <?php
/**
* @group conduit
*/
abstract class ConduitAPI_user_Method extends ConduitAPIMethod { abstract class ConduitAPI_user_Method extends ConduitAPIMethod {
public function getApplication() { public function getApplication() {

View file

@ -1,16 +1,20 @@
<?php <?php
/** final class ConduitAPI_user_addstatus_Method
* @group conduit extends ConduitAPI_user_Method {
*/
final class ConduitAPI_user_addstatus_Method extends ConduitAPI_user_Method {
public function getMethodStatus() { public function getMethodStatus() {
return self::METHOD_STATUS_UNSTABLE; return self::METHOD_STATUS_DEPRECATED;
} }
public function getMethodDescription() { public function getMethodDescription() {
return "Add status information to the logged-in user."; return pht("Add status information to the logged-in user.");
}
public function getMethodStatusDescription() {
return pht(
'Statuses are becoming full-fledged events as part of the '.
'Calendar application.');
} }
public function defineParamTypes() { public function defineParamTypes() {

View file

@ -1,16 +1,19 @@
<?php <?php
/**
* @group conduit
*/
final class ConduitAPI_user_removestatus_Method extends ConduitAPI_user_Method { final class ConduitAPI_user_removestatus_Method extends ConduitAPI_user_Method {
public function getMethodStatus() { public function getMethodStatus() {
return self::METHOD_STATUS_UNSTABLE; return self::METHOD_STATUS_DEPRECATED;
} }
public function getMethodDescription() { public function getMethodDescription() {
return "Delete status information of the logged-in user."; return pht("Delete status information of the logged-in user.");
}
public function getMethodStatusDescription() {
return pht(
'Statuses are becoming full-fledged events as part of the '.
'Calendar application.');
} }
public function defineParamTypes() { public function defineParamTypes() {