Apache Solr open-source search software
SOLR-17864: Migrate more system properties (#3617)
Eric Pugh6d482ebc03d5
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/ConfigSetsHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/ConfigSetsHandler.javaindex 535deb54e44..0f0d79d36b9 100644--- a/solr/core/src/java/org/apache/solr/handler/admin/ConfigSetsHandler.java+++ b/solr/core/src/java/org/apache/solr/handler/admin/ConfigSetsHandler.java@@ -51,8 +51,6 @@ import org.slf4j.LoggerFactory;/** A {@link org.apache.solr.request.SolrRequestHandler} for ConfigSets API requests. */public class ConfigSetsHandler extends RequestHandlerBase implements PermissionNameProvider {// TODO refactor into o.a.s.handler.configsets package to live alongside actual API logic- public static final Boolean DISABLE_CREATE_AUTH_CHECKS =- Boolean.getBoolean("solr.disableConfigSetsCreateAuthChecks"); // this is for back compat onlypublic static final String DEFAULT_CONFIGSET_NAME = "_default";public static final String AUTOCREATED_CONFIGSET_SUFFIX = ".AUTOCREATED";private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());diff --git a/solr/core/src/java/org/apache/solr/handler/admin/SystemInfoHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/SystemInfoHandler.javaindex 48e37b699d9..a0544d98b81 100644--- a/solr/core/src/java/org/apache/solr/handler/admin/SystemInfoHandler.java+++ b/solr/core/src/java/org/apache/solr/handler/admin/SystemInfoHandler.java@@ -40,6 +40,7 @@ import org.apache.lucene.util.Version;import org.apache.solr.api.AnnotatedApi;import org.apache.solr.api.Api;import org.apache.solr.common.cloud.ZkStateReader;+import org.apache.solr.common.util.EnvUtils;import org.apache.solr.common.util.SimpleOrderedMap;import org.apache.solr.core.CoreContainer;import org.apache.solr.core.NodeConfig;@@ -76,8 +77,8 @@ public class SystemInfoHandler extends RequestHandlerBase {** @see #initHostname*/- private static final String PREVENT_REVERSE_DNS_OF_LOCALHOST_SYSPROP =- "solr.dns.prevent.reverse.lookup";+ private static final String REVERSE_DNS_OF_LOCALHOST_SYSPROP =+ "solr.admin.handler.systeminfo.dns.reverse.lookup.enabled";// on some platforms, resolving canonical hostname can cause the thread// to block for several seconds if nameservices aren't available@@ -98,10 +99,10 @@ public class SystemInfoHandler extends RequestHandlerBase {}private void initHostname() {- if (null != System.getProperty(PREVENT_REVERSE_DNS_OF_LOCALHOST_SYSPROP, null)) {+ if (!EnvUtils.getPropertyAsBool(REVERSE_DNS_OF_LOCALHOST_SYSPROP, true)) {log.info("Resolving canonical hostname for local host prevented due to '{}' sysprop",- PREVENT_REVERSE_DNS_OF_LOCALHOST_SYSPROP);+ REVERSE_DNS_OF_LOCALHOST_SYSPROP);hostname = null;return;}@@ -112,9 +113,8 @@ public class SystemInfoHandler extends RequestHandlerBase {hostname = addr.getCanonicalHostName();} catch (Exception e) {log.warn(- "Unable to resolve canonical hostname for local host, possible DNS misconfiguration. SET THE '{}' {}",- PREVENT_REVERSE_DNS_OF_LOCALHOST_SYSPROP,- " sysprop to true on startup to prevent future lookups if DNS can not be fixed.",+ "Unable to resolve canonical hostname for local host, possible DNS misconfiguration. Set the '{}' sysprop to false on startup to prevent future lookups if DNS can not be fixed.",+ REVERSE_DNS_OF_LOCALHOST_SYSPROP,e);hostname = null;return;@@ -124,10 +124,9 @@ public class SystemInfoHandler extends RequestHandlerBase {if (15000D < timer.getTime()) {String readableTime = String.format(Locale.ROOT, "%.3f", (timer.getTime() / 1000));log.warn(- "Resolving canonical hostname for local host took {} seconds, possible DNS misconfiguration. Set the '{}' {}",+ "Resolving canonical hostname for local host took {} seconds, possible DNS misconfiguration. Set the '{}' sysprop to false on startup to prevent future lookups if DNS can not be fixed.",readableTime,- PREVENT_REVERSE_DNS_OF_LOCALHOST_SYSPROP,- " sysprop to true on startup to prevent future lookups if DNS can not be fixed.");+ REVERSE_DNS_OF_LOCALHOST_SYSPROP);}}diff --git a/solr/core/src/java/org/apache/solr/update/PeerSync.java b/solr/core/src/java/org/apache/solr/update/PeerSync.javaindex 006ba4f3297..a37edab2db3 100644--- a/solr/core/src/java/org/apache/solr/update/PeerSync.java+++ b/solr/core/src/java/org/apache/solr/update/PeerSync.java@@ -40,6 +40,7 @@ import org.apache.solr.cloud.ZkController;import org.apache.solr.common.SolrException;import org.apache.solr.common.SolrInputDocument;import org.apache.solr.common.params.ModifiableSolrParams;+import org.apache.solr.common.util.EnvUtils;import org.apache.solr.common.util.IOUtils;import org.apache.solr.core.SolrCore;import org.apache.solr.core.SolrInfoBean;@@ -120,7 +121,8 @@ public class PeerSync implements SolrMetricProducer {this.nUpdates = nUpdates;this.cantReachIsSuccess = cantReachIsSuccess;this.doFingerprint =- doFingerprint && !("true".equals(System.getProperty("solr.disableFingerprint")));+ doFingerprint+ && EnvUtils.getPropertyAsBool("solr.index.replication.fingerprint.enabled", true);this.onlyIfActive = onlyIfActive;uhandler = core.getUpdateHandler();diff --git a/solr/core/src/java/org/apache/solr/update/PeerSyncWithLeader.java b/solr/core/src/java/org/apache/solr/update/PeerSyncWithLeader.javaindex f46e0c161e7..50af7b050ea 100644--- a/solr/core/src/java/org/apache/solr/update/PeerSyncWithLeader.java+++ b/solr/core/src/java/org/apache/solr/update/PeerSyncWithLeader.java@@ -36,6 +36,7 @@ import org.apache.solr.client.solrj.response.QueryResponse;import org.apache.solr.cloud.ZkController;import org.apache.solr.common.SolrException;import org.apache.solr.common.params.ModifiableSolrParams;+import org.apache.solr.common.util.EnvUtils;import org.apache.solr.common.util.NamedList;import org.apache.solr.common.util.URLUtil;import org.apache.solr.core.SolrCore;@@ -76,7 +77,8 @@ public class PeerSyncWithLeader implements SolrMetricProducer {this.leaderUrl = leaderUrl;this.nUpdates = nUpdates;- this.doFingerprint = !"true".equals(System.getProperty("solr.disableFingerprint"));+ this.doFingerprint =+ EnvUtils.getPropertyAsBool("solr.index.replication.fingerprint.enabled", true);this.uhandler = core.getUpdateHandler();this.ulog = uhandler.getUpdateLog();diff --git a/solr/core/src/test/org/apache/solr/cloud/LeaderFailureAfterFreshStartTest.java b/solr/core/src/test/org/apache/solr/cloud/LeaderFailureAfterFreshStartTest.javaindex fb297fbdca2..c32b4694f95 100644--- a/solr/core/src/test/org/apache/solr/cloud/LeaderFailureAfterFreshStartTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/LeaderFailureAfterFreshStartTest.java@@ -163,7 +163,7 @@ public class LeaderFailureAfterFreshStartTest extends AbstractFullDistribZkTestBsuccess = true;} finally {- System.clearProperty("solr.disableFingerprint");+ System.clearProperty("solr.index.replication.fingerprint.enabled");}}diff --git a/solr/core/src/test/org/apache/solr/cloud/PeerSyncReplicationTest.java b/solr/core/src/test/org/apache/solr/cloud/PeerSyncReplicationTest.javaindex 6695fcef951..128423b736a 100644--- a/solr/core/src/test/org/apache/solr/cloud/PeerSyncReplicationTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/PeerSyncReplicationTest.java@@ -131,7 +131,7 @@ public class PeerSyncReplicationTest extends AbstractFullDistribZkTestBase {// node failure and recovery via PeerSynclog.info("Forcing PeerSync");- CloudJettyRunner nodePeerSynced = forceNodeFailureAndDoPeerSync(false);+ CloudJettyRunner nodePeerSynced = forceNodeFailureAndDoPeerSync(true);// add a few more docsindexDoc(id, docId, i1, 50, tlong, 50, t1, "document number " + docId++);@@ -197,7 +197,7 @@ public class PeerSyncReplicationTest extends AbstractFullDistribZkTestBase {assertEquals(0L, counter.getCount());success = true;} finally {- System.clearProperty("solr.disableFingerprint");+ System.clearProperty("solr.index.replication.fingerprint.enabled");}}@@ -263,7 +263,7 @@ public class PeerSyncReplicationTest extends AbstractFullDistribZkTestBase {nodesDown.addAll(replicasToShutDown);}- private CloudJettyRunner forceNodeFailureAndDoPeerSync(boolean disableFingerprint)+ private CloudJettyRunner forceNodeFailureAndDoPeerSync(boolean enableFingerprint)throws Exception {// kill non leader - new leader could have all the docs or be missing oneCloudJettyRunner leaderJetty = shardToLeaderJetty.get("shard1");@@ -279,15 +279,16 @@ public class PeerSyncReplicationTest extends AbstractFullDistribZkTestBase {indexDoc(id, docId, i1, 50, tlong, 50, t1, "document number " + docId++);commit();- bringUpDeadNodeAndEnsureNoReplication(replicaToShutDown, disableFingerprint);+ bringUpDeadNodeAndEnsureNoReplication(replicaToShutDown, enableFingerprint);return replicaToShutDown;}private void bringUpDeadNodeAndEnsureNoReplication(- CloudJettyRunner nodeToBringUp, boolean disableFingerprint) throws Exception {+ CloudJettyRunner nodeToBringUp, boolean enableFingerprint) throws Exception {// disable fingerprint check if needed- System.setProperty("solr.disableFingerprint", String.valueOf(disableFingerprint));+ System.setProperty(+ "solr.index.replication.fingerprint.enabled", String.valueOf(enableFingerprint));// we wait a little while, so socket between leader -> replica will be timeoutThread.sleep(3000);IndexInBackGround iib = new IndexInBackGround(50, nodeToBringUp);diff --git a/solr/core/src/test/org/apache/solr/update/PeerSyncTest.java b/solr/core/src/test/org/apache/solr/update/PeerSyncTest.javaindex 7c90901d00d..aa7d02d6c1c 100644--- a/solr/core/src/test/org/apache/solr/update/PeerSyncTest.java+++ b/solr/core/src/test/org/apache/solr/update/PeerSyncTest.java@@ -231,11 +231,11 @@ public class PeerSyncTest extends BaseDistributedSearchTestCase {assertSync(client1, numVersions, false, shardsArr[0]);// if we turn off fingerprinting, it should succeed- System.setProperty("solr.disableFingerprint", "true");+ System.setProperty("solr.index.replication.fingerprint.enabled", "false");try {assertSync(client1, numVersions, true, shardsArr[0]);} finally {- System.clearProperty("solr.disableFingerprint");+ System.clearProperty("solr.index.replication.fingerprint.enabled");}// let's add the missing document and verify that order doesn't matterdiff --git a/solr/modules/jwt-auth/src/java/org/apache/solr/security/jwt/JWTIssuerConfig.java b/solr/modules/jwt-auth/src/java/org/apache/solr/security/jwt/JWTIssuerConfig.javaindex 7e479be74d4..c0e074888a8 100644--- a/solr/modules/jwt-auth/src/java/org/apache/solr/security/jwt/JWTIssuerConfig.java+++ b/solr/modules/jwt-auth/src/java/org/apache/solr/security/jwt/JWTIssuerConfig.java@@ -80,9 +80,9 @@ public class JWTIssuerConfig {private Collection<X509Certificate> trustedCerts;public static boolean ALLOW_OUTBOUND_HTTP =- Boolean.parseBoolean(EnvUtils.getProperty("solr.auth.jwt.allowOutboundHttp", "false"));+ EnvUtils.getPropertyAsBool("solr.auth.jwt.outbound.http.enabled", false);public static final String ALLOW_OUTBOUND_HTTP_ERR_MSG =- "HTTPS required for IDP communication. Please use SSL or start your nodes with -Dsolr.auth.jwt.allowOutboundHttp=true to allow HTTP for test purposes.";+ "HTTPS required for IDP communication. Please use SSL or start your nodes with -Dsolr.auth.jwt.outbound.http.enabled=true to allow HTTP for test purposes.";private static final String DEFAULT_AUTHORIZATION_FLOW ="implicit"; // 'implicit' to be deprecatedprivate static final Set<String> VALID_AUTHORIZATION_FLOWS =diff --git a/solr/modules/jwt-auth/src/test/org/apache/solr/security/jwt/JWTIssuerConfigTest.java b/solr/modules/jwt-auth/src/test/org/apache/solr/security/jwt/JWTIssuerConfigTest.javaindex 6416b60c61c..b208e73a1f3 100644--- a/solr/modules/jwt-auth/src/test/org/apache/solr/security/jwt/JWTIssuerConfigTest.java+++ b/solr/modules/jwt-auth/src/test/org/apache/solr/security/jwt/JWTIssuerConfigTest.java@@ -157,7 +157,7 @@ public class JWTIssuerConfigTest extends SolrTestCase {SolrException e = expectThrows(SolrException.class, issuerConfig::getHttpsJwks);assertEquals(400, e.code());assertEquals(- "jwksUrl is using http protocol. HTTPS required for IDP communication. Please use SSL or start your nodes with -Dsolr.auth.jwt.allowOutboundHttp=true to allow HTTP for test purposes.",+ "jwksUrl is using http protocol. HTTPS required for IDP communication. Please use SSL or start your nodes with -Dsolr.auth.jwt.outbound.http.enabled=true to allow HTTP for test purposes.",e.getMessage());JWTIssuerConfig.ALLOW_OUTBOUND_HTTP = true;@@ -210,7 +210,7 @@ public class JWTIssuerConfigTest extends SolrTestCase {"http://127.0.0.1:45678/.well-known/config"));assertEquals(400, e.code());assertEquals(- "wellKnownUrl is using http protocol. HTTPS required for IDP communication. Please use SSL or start your nodes with -Dsolr.auth.jwt.allowOutboundHttp=true to allow HTTP for test purposes.",+ "wellKnownUrl is using http protocol. HTTPS required for IDP communication. Please use SSL or start your nodes with -Dsolr.auth.jwt.outbound.http.enabled=true to allow HTTP for test purposes.",e.getMessage());JWTIssuerConfig.ALLOW_OUTBOUND_HTTP = true;diff --git a/solr/solr-ref-guide/modules/deployment-guide/pages/jwt-authentication-plugin.adoc b/solr/solr-ref-guide/modules/deployment-guide/pages/jwt-authentication-plugin.adocindex 4a5094f6225..9c8551033f1 100644--- a/solr/solr-ref-guide/modules/deployment-guide/pages/jwt-authentication-plugin.adoc+++ b/solr/solr-ref-guide/modules/deployment-guide/pages/jwt-authentication-plugin.adoc@@ -186,7 +186,7 @@ A token's 'aud' claim must match 'aud' for one of the configured issuers.=== Using non-SSL URLsIn production environments you should always use SSL protected HTTPS connections, otherwise you open yourself up to attacks.However, in development, it may be useful to use regular HTTP URLs, and bypass the security check that Solr performs.-To support this you can set the system property `-Dsolr.auth.jwt.allowOutboundHttp=true` at startup.+To support this you can set the system property `-Dsolr.auth.jwt.outbound.http.enabled=true` at startup.=== Trusting the IdP serverAll communication with the Oauth2 server (IdP) is done over HTTPS.diff --git a/solr/solr-ref-guide/modules/deployment-guide/pages/zookeeper-access-control.adoc b/solr/solr-ref-guide/modules/deployment-guide/pages/zookeeper-access-control.adocindex d931ee1cd01..b7b095c4bd8 100644--- a/solr/solr-ref-guide/modules/deployment-guide/pages/zookeeper-access-control.adoc+++ b/solr/solr-ref-guide/modules/deployment-guide/pages/zookeeper-access-control.adoc@@ -223,7 +223,7 @@ by `SecurityAwareZkACLProvider` (`/security.json` and `/security/*`) and both adThe `all` and `read` users are injected through the `ZkCredentialsInjector` described earlier in the page.* `org.apache.solr.common.cloud.SaslZkACLProvider`: Requires SASL authentication. Gives all permissions for the user specified in system-property `solr.authorization.superuser` (default:`solr`) when using SASL, and gives read permissions for anyone else. Designed for+property `solr.auth.superuser` (default:`solr`) when using SASL, and gives read permissions for anyone else. Designed fora setup where configurations have already been set up and will not be modified, or where configuration changes arecontrolled via Solr APIs. This provider will be useful for administration in a kerberos environment. In suchan environment, the administrator wants Solr to authenticate to ZooKeeper using SASL, since this is only way todiff --git a/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/SaslZkACLProvider.java b/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/SaslZkACLProvider.javaindex ca2ba3bfe0a..c111bfa0dfb 100644--- a/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/SaslZkACLProvider.java+++ b/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/SaslZkACLProvider.java@@ -18,20 +18,20 @@ package org.apache.solr.common.cloud;import java.util.Arrays;import java.util.List;+import org.apache.solr.common.util.EnvUtils;import org.apache.zookeeper.ZooDefs;import org.apache.zookeeper.data.ACL;import org.apache.zookeeper.data.Id;/*** ZkACLProvider that gives all permissions for the user specified in System property- * "solr.authorization.superuser" (default: "solr") when using sasl, and gives read permissions for- * anyone else. Designed for a setup where configurations have already been set up and will not be+ * "solr.auth.superuser" (default: "solr") when using sasl, and gives read permissions for anyone+ * else. Designed for a setup where configurations have already been set up and will not be* modified, or where configuration changes are controlled via Solr APIs.*/public class SaslZkACLProvider extends SecurityAwareZkACLProvider {- private static final String superUser =- System.getProperty("solr.authorization.superuser", "solr");+ private static final String superUser = EnvUtils.getProperty("solr.auth.superuser", "solr");@Overrideprotected List<ACL> createNonSecurityACLsToAdd() {diff --git a/solr/solrj/src/resources/DeprecatedSystemPropertyMappings.properties b/solr/solrj/src/resources/DeprecatedSystemPropertyMappings.propertiesindex 05fb16c227e..517b66676c1 100644--- a/solr/solrj/src/resources/DeprecatedSystemPropertyMappings.properties+++ b/solr/solrj/src/resources/DeprecatedSystemPropertyMappings.properties@@ -1,14 +1,19 @@# Mapping current system property name to legacy system property names# This file only contains non-standard mappings that do not follow the standard naming conversion convention# You do not need a entry for a solrMyProperty to solr.my.property conversion-# We have inverted the meaning of some properties, and therefore they have a =! pattern.+# However, if you are renaming solrMyProperty to solr.my.special.property, then use solr.my.property for the legacy name+# We have inverted the meaning of some properties, and therefore they have a =! pattern to facilitate backwards compatibility# To be removed in Solr 12:# To be removed in Solr 11:+solr.admin.handler.systeminfo.dns.reverse.lookup.enabled=!solr.dns.prevent.reverse.lookupsolr.api.config.edit.enabled=!disable.config.editsolr.api.v2.enabled=!disable.v2.api+solr.auth.jwt.outbound.http.enabled=solr.auth.jwt.allow.outbound.http+solr.auth.superuser=solr.authorization.superuser+solr.cloud.prep.recovery.read.timeout.additional.ms=prep.recovery.read.timeout.extra.waitsolr.cloud.startup.delete.unknown.cores.enabled=solr.delete.unknown.coressolr.cloud.wait.for.zk.seconds=solr.wait.for.zk@@ -17,11 +22,12 @@ solr.configset.bootstrap.confdir=bootstrap_confdirsolr.configset.bootstrap.config.name=collection.configNamesolr.configset.default.confdir=solr.default.confdirsolr.configset.forbidden.file.types=solr.config.set.forbidden.file.types-solr.configset.forbidden.file.types=solrConfigSetForbiddenFileTypessolr.configset.upload.enabled=configset.upload.enabledsolr.filestore.filesize.max=max.file.store.size+solr.index.replication.fingerprint.enabled=!solr.disableFingerprint+solr.logs.dir=solr.log.dirsolr.metrics.fieldcache.entries.enabled=!disable.solr.field.cache.m.bean.entry.listdiff --git a/solr/solrj/src/test/org/apache/solr/common/util/EnvUtilsTest.java b/solr/solrj/src/test/org/apache/solr/common/util/EnvUtilsTest.javaindex 1c549e8571c..77461d4110a 100644--- a/solr/solrj/src/test/org/apache/solr/common/util/EnvUtilsTest.java+++ b/solr/solrj/src/test/org/apache/solr/common/util/EnvUtilsTest.java@@ -104,7 +104,8 @@ public class EnvUtilsTest extends SolrTestCase {public void testDeprecated() {var env = Map.of("SOLR_OVERWRITE", "overwritten");Properties defaultProps = new Properties();- defaultProps.setProperty("solrConfigSetForbiddenFileTypes", "xml,json,jar");+ // Use the already converted version, not the original camelCase.+ defaultProps.setProperty("solr.config.set.forbidden.file.types", "xml,json,jar");EnvUtils.init(false, env, defaultProps);assertEquals("xml,json,jar", EnvUtils.getProperty("solr.configset.forbidden.file.types"));