vyatkinv commented on code in PR #4320: URL: https://github.com/apache/solr/pull/4320#discussion_r3294305566
########## solr/core/src/test/org/apache/solr/core/InternalSolrClientCacheTest.java: ########## @@ -0,0 +1,121 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.solr.core; + +import java.util.Map; +import org.apache.solr.client.solrj.impl.CloudSolrClient; +import org.apache.solr.client.solrj.io.SolrClientCache; +import org.apache.solr.cloud.SolrCloudTestCase; +import org.apache.solr.common.SolrException; +import org.apache.solr.common.cloud.DigestZkACLProvider; +import org.apache.solr.common.cloud.DigestZkCredentialsProvider; +import org.apache.solr.common.cloud.SolrZkClient; +import org.apache.solr.common.cloud.VMParamsZkCredentialsInjector; +import org.apache.solr.metrics.SolrMetricsContext; +import org.apache.solr.security.MockSolrMetricsContextFactory; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +public class InternalSolrClientCacheTest extends SolrCloudTestCase { + private static final Map<String, String> sysProps = + Map.of( + SolrZkClient.ZK_CREDENTIALS_INJECTOR_CLASS_NAME_VM_PARAM_NAME, + VMParamsZkCredentialsInjector.class.getName(), + SolrZkClient.ZK_CRED_PROVIDER_CLASS_NAME_VM_PARAM_NAME, + DigestZkCredentialsProvider.class.getName(), + SolrZkClient.ZK_ACL_PROVIDER_CLASS_NAME_VM_PARAM_NAME, + DigestZkACLProvider.class.getName(), + VMParamsZkCredentialsInjector.DEFAULT_DIGEST_USERNAME_VM_PARAM_NAME, + "admin-user", + VMParamsZkCredentialsInjector.DEFAULT_DIGEST_PASSWORD_VM_PARAM_NAME, + "pass", + VMParamsZkCredentialsInjector.DEFAULT_DIGEST_READONLY_USERNAME_VM_PARAM_NAME, + "read-user", + VMParamsZkCredentialsInjector.DEFAULT_DIGEST_READONLY_PASSWORD_VM_PARAM_NAME, + "pass"); + + @BeforeClass + public static void before() throws Exception { + sysProps.forEach(System::setProperty); + configureCluster(1) + .formatZkServer(true) + .addConfig( + "conf", TEST_PATH().resolve("configsets").resolve("cloud-minimal").resolve("conf")) + .configure(); + } + + @AfterClass + public static void after() { + sysProps.keySet().forEach(System::clearProperty); + } + + @After + public void afterEach() { + System.clearProperty("solr.allow-external-clusters"); + } + + @Test + public void testSelfClusterShouldBeAllowed() { + final SolrMetricsContext metricsContext = MockSolrMetricsContextFactory.create(); + try (HttpSolrClientProvider httpSolrClientProvider = + new HttpSolrClientProvider(null, metricsContext)) { Review Comment: done ########## solr/solrj-streaming/src/java/org/apache/solr/client/solrj/io/SolrClientCache.java: ########## @@ -67,15 +65,19 @@ public void setBasicAuthCredentials(String basicAuthCredentials) { this.basicAuthCredentials = basicAuthCredentials; } - public void setDefaultZKHost(String zkHost) { - if (zkHost != null) { - zkHost = zkHost.split("/")[0]; - if (!zkHost.isEmpty()) { - defaultZkHost.set(zkHost); - } else { - defaultZkHost.set(null); - } - } + /** + * Controls whether ZooKeeper ACL credentials may be propagated to ZooKeeper hosts used by {@link + * CloudSolrClient} instances created by this cache. + * + * <p>This option is disabled by default for security reasons. Enabling it may expose ZooKeeper + * credentials to external or untrusted ZooKeeper ensembles if arbitrary cluster connections are + * allowed. + * + * @param useZookeeperACL whether ZooKeeper ACL credentials should be used by clients created from + * this cache + */ + public void setUseZookeeperACL(boolean useZookeeperACL) { + this.useZookeeperACL = useZookeeperACL; } Review Comment: done -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
