Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-16631: solr.allowUrls - hostnames should be treated in case insensitive way (#1325)

Paul Blanchaert7a33c191341e
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index ecc780988a9..d4c049f22f0 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -187,6 +187,8 @@ Bug Fixes
* SOLR-16621: Admin UI fails to grant user permissions that have wildcard role (janhoy)
+* SOLR-16631: solr.allowUrls (former solr.shardsWhitelist) should treat hostnames in case insensitive way. (Paul Blanchaert via Eric Pugh)
+
Build
---------------------
* Upgrade forbiddenapis to 3.4 (Uwe Schindler)
diff --git a/solr/core/src/java/org/apache/solr/security/AllowListUrlChecker.java b/solr/core/src/java/org/apache/solr/security/AllowListUrlChecker.java
index f005cd0f75f..1354fde0ec7 100644
--- a/solr/core/src/java/org/apache/solr/security/AllowListUrlChecker.java
+++ b/solr/core/src/java/org/apache/solr/security/AllowListUrlChecker.java
@@ -140,7 +140,8 @@ public class AllowListUrlChecker {
clusterState == null ? Collections.emptySet() : clusterState.getHostAllowList();
for (String url : urls) {
String hostPort = parseHostPort(url);
- if (!clusterHostAllowList.contains(hostPort) && !hostAllowList.contains(hostPort)) {
+ if (clusterHostAllowList.stream().noneMatch(hostPort::equalsIgnoreCase)
+ && hostAllowList.stream().noneMatch(hostPort::equalsIgnoreCase)) {
throw new SolrException(
SolrException.ErrorCode.FORBIDDEN,
"URL "
diff --git a/solr/core/src/test/org/apache/solr/security/AllowListUrlCheckerTest.java b/solr/core/src/test/org/apache/solr/security/AllowListUrlCheckerTest.java
index 394c847260f..56da97d24a1 100644
--- a/solr/core/src/test/org/apache/solr/security/AllowListUrlCheckerTest.java
+++ b/solr/core/src/test/org/apache/solr/security/AllowListUrlCheckerTest.java
@@ -55,14 +55,14 @@ public class AllowListUrlCheckerTest extends SolrTestCaseJ4 {
@Test
public void testSingleHost() throws Exception {
AllowListUrlChecker checker = new AllowListUrlChecker(urls("http://abc-1.com:8983/solr"));
- checker.checkAllowList(urls("http://abc-1.com:8983/solr"));
+ checker.checkAllowList(urls("http://Abc-1.Com:8983/solr"));
}
@Test
public void testMultipleHosts() throws Exception {
AllowListUrlChecker checker =
new AllowListUrlChecker(
- urls("http://abc-1.com:8983", "http://abc-2.com:8983", "http://abc-3.com:8983"));
+ urls("http://abc-1.com:8983", "http://abc-2.com:8983", "http://ABC-3.com:8983"));
checker.checkAllowList(
urls(
"http://abc-3.com:8983/solr",