mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-09 16:32:39 +01:00
Move "show all config" from DarkConsole to /config/
Summary: Currently, we have a "config" panel in DarkConsole. It's useful to have a table of all effective config values, but it doesn't need to be in DarkConsole. Move it to Config instead. Basically: - You don't need to activate DarkConsole to see it anymore; - now visible only to admins; - respects config mask/hide; - somewhat prettier; - links to config edit; - no longer ships down on every DarkConsole request with a giant table of rarely-used data. Test Plan: Looked at the table. Looked at lack of table in darkconsole. Reviewers: codeblock, btrahan Reviewed By: codeblock CC: aran Maniphest Tasks: T2255 Differential Revision: https://secure.phabricator.com/D4473
This commit is contained in:
parent
c2a70932e3
commit
6e69523efc
7 changed files with 74 additions and 122 deletions
|
@ -142,26 +142,6 @@ return array(
|
|||
// 'darkconsole.enabled' to use this option.
|
||||
'darkconsole.always-on' => false,
|
||||
|
||||
|
||||
// Allows you to mask certain configuration values from appearing in the
|
||||
// "Config" tab of DarkConsole.
|
||||
'darkconsole.config-mask' => array(
|
||||
'mysql.pass',
|
||||
'amazon-ses.secret-key',
|
||||
'amazon-s3.secret-key',
|
||||
'sendgrid.api-key',
|
||||
'recaptcha.private-key',
|
||||
'phabricator.csrf-key',
|
||||
'facebook.application-secret',
|
||||
'github.application-secret',
|
||||
'google.application-secret',
|
||||
'phabricator.application-secret',
|
||||
'disqus.application-secret',
|
||||
'phabricator.mail-key',
|
||||
'security.hmac-key',
|
||||
'ldap.anonymous-user-password',
|
||||
),
|
||||
|
||||
// Map of additional configuration values to lock.
|
||||
'config.lock' => array(),
|
||||
|
||||
|
@ -171,7 +151,6 @@ return array(
|
|||
// Map of additional configuration values to mask.
|
||||
'config.mask' => array(),
|
||||
|
||||
|
||||
// -- MySQL --------------------------------------------------------------- //
|
||||
|
||||
// Class providing database configuration. It must implement
|
||||
|
|
|
@ -195,7 +195,6 @@ phutil_register_library_map(array(
|
|||
'ConduitCallTestCase' => 'applications/conduit/call/__tests__/ConduitCallTestCase.php',
|
||||
'ConduitException' => 'applications/conduit/protocol/ConduitException.php',
|
||||
'ConduitSSHWorkflow' => 'applications/conduit/ssh/ConduitSSHWorkflow.php',
|
||||
'DarkConsoleConfigPlugin' => 'aphront/console/plugin/DarkConsoleConfigPlugin.php',
|
||||
'DarkConsoleController' => 'aphront/console/DarkConsoleController.php',
|
||||
'DarkConsoleCore' => 'aphront/console/DarkConsoleCore.php',
|
||||
'DarkConsoleErrorLogPlugin' => 'aphront/console/plugin/DarkConsoleErrorLogPlugin.php',
|
||||
|
@ -701,6 +700,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorConduitLogController' => 'applications/conduit/controller/PhabricatorConduitLogController.php',
|
||||
'PhabricatorConduitMethodCallLog' => 'applications/conduit/storage/PhabricatorConduitMethodCallLog.php',
|
||||
'PhabricatorConduitTokenController' => 'applications/conduit/controller/PhabricatorConduitTokenController.php',
|
||||
'PhabricatorConfigAllController' => 'applications/config/controller/PhabricatorConfigAllController.php',
|
||||
'PhabricatorConfigController' => 'applications/config/controller/PhabricatorConfigController.php',
|
||||
'PhabricatorConfigDefaultSource' => 'infrastructure/env/PhabricatorConfigDefaultSource.php',
|
||||
'PhabricatorConfigDictionarySource' => 'infrastructure/env/PhabricatorConfigDictionarySource.php',
|
||||
|
@ -1621,7 +1621,6 @@ phutil_register_library_map(array(
|
|||
'ConduitCallTestCase' => 'PhabricatorTestCase',
|
||||
'ConduitException' => 'Exception',
|
||||
'ConduitSSHWorkflow' => 'PhabricatorSSHWorkflow',
|
||||
'DarkConsoleConfigPlugin' => 'DarkConsolePlugin',
|
||||
'DarkConsoleController' => 'PhabricatorController',
|
||||
'DarkConsoleErrorLogPlugin' => 'DarkConsolePlugin',
|
||||
'DarkConsoleEventPlugin' => 'DarkConsolePlugin',
|
||||
|
@ -2087,6 +2086,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorConduitLogController' => 'PhabricatorConduitController',
|
||||
'PhabricatorConduitMethodCallLog' => 'PhabricatorConduitDAO',
|
||||
'PhabricatorConduitTokenController' => 'PhabricatorConduitController',
|
||||
'PhabricatorConfigAllController' => 'PhabricatorConfigController',
|
||||
'PhabricatorConfigController' => 'PhabricatorController',
|
||||
'PhabricatorConfigDefaultSource' => 'PhabricatorConfigProxySource',
|
||||
'PhabricatorConfigDictionarySource' => 'PhabricatorConfigSource',
|
||||
|
|
|
@ -10,7 +10,6 @@ final class DarkConsoleCore {
|
|||
const PLUGIN_EVENT = 'Event';
|
||||
const PLUGIN_XHPROF = 'XHProf';
|
||||
const PLUGIN_REQUEST = 'Request';
|
||||
const PLUGIN_CONFIG = 'Config';
|
||||
|
||||
public static function getPlugins() {
|
||||
return array(
|
||||
|
@ -19,7 +18,6 @@ final class DarkConsoleCore {
|
|||
self::PLUGIN_SERVICES,
|
||||
self::PLUGIN_EVENT,
|
||||
self::PLUGIN_XHPROF,
|
||||
self::PLUGIN_CONFIG,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,97 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @group console
|
||||
*/
|
||||
final class DarkConsoleConfigPlugin extends DarkConsolePlugin {
|
||||
|
||||
public function getName() {
|
||||
return 'Config';
|
||||
}
|
||||
|
||||
public function getDescription() {
|
||||
return 'Information about Phabricator configuration';
|
||||
}
|
||||
|
||||
public function generateData() {
|
||||
$lib_data = array();
|
||||
foreach (PhutilBootloader::getInstance()->getAllLibraries() as $lib) {
|
||||
$lib_data[$lib] = phutil_get_library_root($lib);
|
||||
}
|
||||
return array(
|
||||
'config' => PhabricatorEnv::getAllConfigKeys(),
|
||||
'libraries' => $lib_data,
|
||||
);
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
$data = $this->getData();
|
||||
|
||||
$lib_data = $data['libraries'];
|
||||
|
||||
$lib_rows = array();
|
||||
foreach ($lib_data as $key => $value) {
|
||||
$lib_rows[] = array(
|
||||
phutil_escape_html($key),
|
||||
phutil_escape_html($value),
|
||||
);
|
||||
}
|
||||
|
||||
$lib_table = new AphrontTableView($lib_rows);
|
||||
$lib_table->setHeaders(
|
||||
array(
|
||||
'Library',
|
||||
'Loaded From',
|
||||
));
|
||||
$lib_table->setColumnClasses(
|
||||
array(
|
||||
'header',
|
||||
'wide wrap',
|
||||
));
|
||||
|
||||
$config_data = $data['config'];
|
||||
ksort($config_data);
|
||||
|
||||
$mask = PhabricatorEnv::getEnvConfig('darkconsole.config-mask');
|
||||
$mask = array_fill_keys($mask, true);
|
||||
|
||||
foreach ($mask as $masked_key => $ignored) {
|
||||
if (!PhabricatorEnv::envConfigExists($masked_key)) {
|
||||
throw new Exception(
|
||||
"Configuration 'darkconsole.config-mask' masks unknown ".
|
||||
"configuration key '".$masked_key."'. If this key has been ".
|
||||
"renamed, you might be accidentally exposing information which you ".
|
||||
"don't intend to.");
|
||||
}
|
||||
}
|
||||
|
||||
$rows = array();
|
||||
foreach ($config_data as $key => $value) {
|
||||
if (empty($mask[$key])) {
|
||||
$display_value = is_array($value) ? json_encode($value) : $value;
|
||||
$display_value = phutil_escape_html($display_value);
|
||||
} else {
|
||||
$display_value = phutil_escape_html('<Masked>');
|
||||
}
|
||||
$rows[] = array(
|
||||
phutil_escape_html($key),
|
||||
$display_value,
|
||||
);
|
||||
}
|
||||
|
||||
$table = new AphrontTableView($rows);
|
||||
$table->setHeaders(
|
||||
array(
|
||||
'Key',
|
||||
'Value',
|
||||
));
|
||||
$table->setColumnClasses(
|
||||
array(
|
||||
'header',
|
||||
'wide wrap',
|
||||
));
|
||||
|
||||
return $lib_table->render().$table->render();
|
||||
}
|
||||
}
|
|
@ -26,6 +26,7 @@ final class PhabricatorApplicationConfig extends PhabricatorApplication {
|
|||
return array(
|
||||
'/config/' => array(
|
||||
'' => 'PhabricatorConfigListController',
|
||||
'all/' => 'PhabricatorConfigAllController',
|
||||
'edit/(?P<key>[\w\.\-]+)/' => 'PhabricatorConfigEditController',
|
||||
'group/(?P<key>[^/]+)/' => 'PhabricatorConfigGroupController',
|
||||
'issue/' => array(
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorConfigAllController
|
||||
extends PhabricatorConfigController {
|
||||
|
||||
public function processRequest() {
|
||||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
|
||||
$rows = array();
|
||||
$options = PhabricatorApplicationConfigOptions::loadAllOptions();
|
||||
foreach ($options as $option) {
|
||||
$key = $option->getKey();
|
||||
|
||||
if ($option->getMasked()) {
|
||||
$value = '<em>'.pht('Masked').'</em>';
|
||||
} else if ($option->getHidden()) {
|
||||
$value = '<em>'.pht('Hidden').'</em>';
|
||||
} else {
|
||||
$value = PhabricatorEnv::getEnvConfig($key);
|
||||
$value = PhabricatorConfigJSON::prettyPrintJSON($value);
|
||||
$value = phutil_escape_html($value);
|
||||
}
|
||||
|
||||
$rows[] = array(
|
||||
phutil_render_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => $this->getApplicationURI('edit/'.$key.'/'),
|
||||
),
|
||||
phutil_escape_html($key)),
|
||||
$value,
|
||||
);
|
||||
}
|
||||
$table = id(new AphrontTableView($rows))
|
||||
->setDeviceReadyTable(true)
|
||||
->setColumnClasses(
|
||||
array(
|
||||
'',
|
||||
'wide',
|
||||
))
|
||||
->setHeaders(
|
||||
array(
|
||||
pht('Key'),
|
||||
pht('Value'),
|
||||
));
|
||||
|
||||
$title = pht('Current Settings');
|
||||
|
||||
$crumbs = $this
|
||||
->buildApplicationCrumbs()
|
||||
->addCrumb(
|
||||
id(new PhabricatorCrumbView())
|
||||
->setName($title));
|
||||
|
||||
$nav = $this->buildSideNavView();
|
||||
$nav->selectFilter('all/');
|
||||
$nav->setCrumbs($crumbs);
|
||||
$nav->appendChild($table);
|
||||
|
||||
return $this->buildApplicationPage(
|
||||
$nav,
|
||||
array(
|
||||
'title' => $title,
|
||||
'device' => true,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -13,6 +13,7 @@ abstract class PhabricatorConfigController extends PhabricatorController {
|
|||
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
|
||||
$nav->addFilter('/', pht('Configuration'));
|
||||
$nav->addFilter('issue/', pht('Setup Issues'));
|
||||
$nav->addFilter('all/', pht('Current Settings'));
|
||||
|
||||
return $nav;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue