Console: Hide sensitive properties on /configadvanced

This commit is contained in:
zzz
2020-05-12 15:38:25 +00:00
parent 1ebed8b6aa
commit a12a26f65c
2 changed files with 31 additions and 3 deletions

View File

@@ -129,8 +129,8 @@ public class RouterConsoleRunner implements RouterApp {
public static final String ROUTERCONSOLE = "routerconsole";
public static final String PREFIX = "webapps.";
public static final String ENABLED = ".startOnLoad";
private static final String PROP_KEYSTORE_PASSWORD = "routerconsole.keystorePassword";
private static final String PROP_KEY_PASSWORD = "routerconsole.keyPassword";
public static final String PROP_KEYSTORE_PASSWORD = "routerconsole.keystorePassword";
public static final String PROP_KEY_PASSWORD = "routerconsole.keyPassword";
public static final int DEFAULT_LISTEN_PORT = PortMapper.DEFAULT_CONSOLE_PORT;
private static final String DEFAULT_WEBAPPS_DIR = "./webapps/";
private static final String USAGE = "Bad RouterConsoleRunner arguments, check clientApp.0.args in your clients.config file! " +

View File

@@ -1,20 +1,48 @@
package net.i2p.router.web.helpers;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import net.i2p.data.DataHelper;
import net.i2p.router.Router;
import net.i2p.router.web.HelperBase;
import net.i2p.router.web.RouterConsoleRunner;
public class ConfigAdvancedHelper extends HelperBase {
static final String PROP_FLOODFILL_PARTICIPANT = "router.floodfillParticipant";
private static final String PROP_AUTH_PFX = RouterConsoleRunner.PROP_CONSOLE_PW + '.';
private static final Set<String> _hideKeys;
static {
// do not show these settings in the UI
String[] keys = {
"i2cp.keyPassword", "i2cp.keystorePassword",
"i2np.ntcp2.sp",
"netdb.family.keyPassword", "netdb.family.keystorePassword",
Router.PROP_IB_RANDOM_KEY, Router.PROP_OB_RANDOM_KEY,
"router.reseedProxy.password", "router.reseedSSLProxy.password",
RouterConsoleRunner.PROP_KEY_PASSWORD, RouterConsoleRunner.PROP_KEYSTORE_PASSWORD
};
_hideKeys = new HashSet<String>(Arrays.asList(keys));
}
public String getSettings() {
StringBuilder buf = new StringBuilder(4*1024);
TreeMap<String, String> sorted = new TreeMap<String, String>();
sorted.putAll(_context.router().getConfigMap());
boolean adv = isAdvanced();
for (Map.Entry<String, String> e : sorted.entrySet()) {
String name = DataHelper.escapeHTML(e.getKey());
String key = e.getKey();
if (!adv &&
( _hideKeys.contains(key) ||
key.startsWith("i2cp.auth.") ||
key.startsWith(PROP_AUTH_PFX))) {
continue;
}
String name = DataHelper.escapeHTML(key);
String val = DataHelper.escapeHTML(e.getValue());
buf.append(name).append('=').append(val).append('\n');
}