forked from apache/lucene-solr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SOLR-14569: Configuring a shardHandlerFactory on the /select requestH…
…andler results in HTTP 401 when searching on alias in secured Solr. (apache#574) Conflicts: .gitignore solr/core/src/java/org/apache/solr/core/CoreContainer.java
- Loading branch information
1 parent
9a11380
commit d2de09d
Showing
9 changed files
with
235 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
solr/core/src/test-files/solr/configsets/cloud-minimal_override-shardHandler/conf/schema.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<!-- | ||
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. | ||
--> | ||
<schema name="minimal" version="1.1"> | ||
<fieldType name="string" class="solr.StrField"/> | ||
<fieldType name="int" class="${solr.tests.IntegerFieldType}" docValues="${solr.tests.numeric.dv}" precisionStep="0" omitNorms="true" positionIncrementGap="0"/> | ||
<fieldType name="long" class="${solr.tests.LongFieldType}" docValues="${solr.tests.numeric.dv}" precisionStep="0" omitNorms="true" positionIncrementGap="0"/> | ||
<dynamicField name="*" type="string" indexed="true" stored="true"/> | ||
<!-- for versioning --> | ||
<field name="_version_" type="long" indexed="true" stored="true"/> | ||
<field name="_root_" type="string" indexed="true" stored="true" multiValued="false" required="false"/> | ||
<field name="id" type="string" indexed="true" stored="true"/> | ||
<dynamicField name="*_s" type="string" indexed="true" stored="true" /> | ||
<uniqueKey>id</uniqueKey> | ||
</schema> |
56 changes: 56 additions & 0 deletions
56
...re/src/test-files/solr/configsets/cloud-minimal_override-shardHandler/conf/solrconfig.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?xml version="1.0" ?> | ||
|
||
<!-- | ||
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. | ||
--> | ||
|
||
<!-- Minimal solrconfig.xml with /select, /admin and /update only --> | ||
|
||
<config> | ||
|
||
<dataDir>${solr.data.dir:}</dataDir> | ||
|
||
<directoryFactory name="DirectoryFactory" | ||
class="${solr.directoryFactory:solr.NRTCachingDirectoryFactory}"/> | ||
<schemaFactory class="ClassicIndexSchemaFactory"/> | ||
|
||
<luceneMatchVersion>${tests.luceneMatchVersion:LATEST}</luceneMatchVersion> | ||
|
||
<updateHandler class="solr.DirectUpdateHandler2"> | ||
<commitWithin> | ||
<softCommit>${solr.commitwithin.softcommit:true}</softCommit> | ||
</commitWithin> | ||
<updateLog class="${solr.ulog:solr.UpdateLog}"></updateLog> | ||
</updateHandler> | ||
|
||
<requestHandler name="/select" class="solr.SearchHandler"> | ||
<shardHandlerFactory class="HttpShardHandlerFactory"> | ||
<int name="socketTimeOut">1000</int> | ||
<int name="connTimeOut">5000</int> | ||
<int name="corePoolSize">5</int> | ||
</shardHandlerFactory> | ||
<lst name="defaults"> | ||
<str name="echoParams">explicit</str> | ||
<str name="indent">true</str> | ||
<str name="df">text</str> | ||
</lst> | ||
</requestHandler> | ||
|
||
<indexConfig> | ||
<mergeScheduler class="${solr.mscheduler:org.apache.lucene.index.ConcurrentMergeScheduler}"/> | ||
: </indexConfig> | ||
</config> | ||
|
117 changes: 117 additions & 0 deletions
117
solr/core/src/test/org/apache/solr/security/AuthWithShardHandlerFactoryOverrideTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
/* | ||
* 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.security; | ||
|
||
import org.apache.solr.client.solrj.SolrResponse; | ||
import org.apache.solr.client.solrj.embedded.JettySolrRunner; | ||
import org.apache.solr.client.solrj.impl.Http2SolrClient; | ||
import org.apache.solr.client.solrj.request.CollectionAdminRequest; | ||
import org.apache.solr.client.solrj.request.QueryRequest; | ||
import org.apache.solr.cloud.SolrCloudAuthTestCase; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
/** | ||
* Similar to BasicAuthOnSingleNodeTest, but using a different configset, to test SOLR-14569 | ||
*/ | ||
public class AuthWithShardHandlerFactoryOverrideTest extends SolrCloudAuthTestCase { | ||
|
||
private static final String COLLECTION = "authCollection"; | ||
private static final String ALIAS = "alias"; | ||
|
||
private static final String SECURITY_CONF = "{\n" + | ||
" \"authentication\":{\n" + | ||
" \"blockUnknown\": true,\n" + | ||
" \"class\":\"solr.BasicAuthPlugin\",\n" + | ||
" \"credentials\":{\"solr\":\"EEKn7ywYk5jY8vG9TyqlG2jvYuvh1Q7kCCor6Hqm320= 6zkmjMjkMKyJX6/f0VarEWQujju5BzxZXub6WOrEKCw=\"}\n" + | ||
" },\n" + | ||
" \"authorization\":{\n" + | ||
" \"class\":\"solr.RuleBasedAuthorizationPlugin\",\n" + | ||
" \"permissions\":[\n" + | ||
" {\"name\":\"all\", \"role\":\"admin\"}\n" + | ||
" ],\n" + | ||
" \"user-role\":{\"solr\":\"admin\"}\n" + | ||
" }\n" + | ||
"}"; | ||
|
||
@Before | ||
public void setupCluster() throws Exception { | ||
configureCluster(1) | ||
.addConfig("conf", configset("cloud-minimal_override-shardHandler")) | ||
.withSecurityJson(SECURITY_CONF) | ||
.configure(); | ||
CollectionAdminRequest.createCollection(COLLECTION, "conf", 4, 1) | ||
.setMaxShardsPerNode(100) | ||
.setBasicAuthCredentials("solr", "solr") | ||
.process(cluster.getSolrClient()); | ||
|
||
CollectionAdminRequest.createAlias(ALIAS, COLLECTION) | ||
.setBasicAuthCredentials("solr", "solr") | ||
.process(cluster.getSolrClient()); | ||
|
||
cluster.waitForActiveCollection(COLLECTION, 4, 4); | ||
|
||
JettySolrRunner jetty = cluster.getJettySolrRunner(0); | ||
jetty.stop(); | ||
cluster.waitForJettyToStop(jetty); | ||
jetty.start(); | ||
cluster.waitForAllNodes(30); | ||
cluster.waitForActiveCollection(COLLECTION, 4, 4); | ||
} | ||
|
||
@Override | ||
@After | ||
public void tearDown() throws Exception { | ||
cluster.shutdown(); | ||
super.tearDown(); | ||
} | ||
|
||
@Test | ||
public void collectionTest() throws Exception { | ||
try (Http2SolrClient client = new Http2SolrClient.Builder(cluster.getJettySolrRunner(0).getBaseUrl().toString()) | ||
.build()){ | ||
|
||
for (int i = 0; i < 30; i++) { | ||
SolrResponse response = new QueryRequest(params("q", "*:*")) | ||
.setBasicAuthCredentials("solr", "solr").process(client, COLLECTION); | ||
// likely to be non-null, even if an error occurred | ||
assertNotNull(response); | ||
assertNotNull(response.getResponse()); | ||
// now we know we have results | ||
assertNotNull(response.getResponse().get("response")); | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
public void aliasTest() throws Exception { | ||
try (Http2SolrClient client = new Http2SolrClient.Builder(cluster.getJettySolrRunner(0).getBaseUrl().toString()) | ||
.build()){ | ||
|
||
for (int i = 0; i < 30; i++) { | ||
SolrResponse response = new QueryRequest(params("q", "*:*")) | ||
.setBasicAuthCredentials("solr", "solr").process(client, ALIAS); | ||
// likely to be non-null, even if an error occurred | ||
assertNotNull(response); | ||
assertNotNull(response.getResponse()); | ||
// now we know we have results | ||
assertNotNull(response.getResponse().get("response")); | ||
} | ||
} | ||
} | ||
} |