Hi,

  I'm facing this issue where SolrJ calls are randomly failing on basic
authentication. Here's exception:

ERROR923629[qtp466002798-20] -
org.apache.solr.security.PKIAuthenticationPlugin.doAuthenticate(PKIAuthenticationPlugin.java:125)
- Invalid key
 INFO923630[qtp466002798-20] -
org.apache.solr.security.RuleBasedAuthorizationPlugin.checkPathPerm(RuleBasedAuthorizationPlugin.java:144)
- request has come without principal. failed permission
org.apache.solr.security.RuleBasedAuthorizationPlugin$Permission@1a343033
INFO923630[qtp466002798-20] -
org.apache.solr.servlet.HttpSolrCall.call(HttpSolrCall.java:429) -
USER_REQUIRED auth header null context : userPrincipal: [null] type:
[READ], collections: [knowledge,], Path: [/select] path : /select params
:df=text&distrib=false&qt=/select&preferLocalShards=false&fl=id&fl=score&shards.purpose=4&start=0&fsv=true&shard.url=
http://xx.xxx.x.222:8983/solr/knowledge/|http://xx.xxx.xxx.246:8983/solr/knowledge/&rows=3&version=2&q=*:*&NOW=1463512962899&isShard=true&wt=javabin

Here's my security.json. I've protected "browse" and "select" request
handler for my queries.

{
  "authentication": {
    "blockUnknown": false,
    "class": "solr.BasicAuthPlugin",
    "credentials": {
      "solr": "IV0EHq1OnNrj6gvRCwvFwTrZ1+z1oBbnQdiVC3otuq0=
Ndd7LKvVBAaZIF0QAVi1ekCfAJXr1GGfLtRUXhgrF8c="
    }
  },
  "authorization": {
    "class": "solr.RuleBasedAuthorizationPlugin",
    "user-role": {
      "solr": "admin",
      "solradmin": "admin",
      "beehive": "dev",
      "readuser": "read"
    },
    "permissions": [
      {
        "name": "security-edit",
        "role": "admin"
      },
      {
        "name": "browse",
        "collection": "knowledge",
        "path": "/browse",
        "role": [
          "admin",
          "dev",
          "read"
        ]
      },
      {
        "name": "select",
        "collection": "knowledge",
        "path": "/select",
        "role": [
          "admin",
          "dev",
          "read"
        ]
      },
      {
        "name": "admin-ui",
        "path": "/",
        "role": [
          "admin",
          "dev"
        ]
      },
      {
        "name": "update",
        "role": [
          "admin",
          "dev"
        ]
      },
      {
        "name": "collection-admin-edit",
        "role": [
          "admin"
        ]
      },
      {
        "name": "schema-edit",
        "role": [
          "admin"
        ]
      },
      {
        "name": "config-edit",
        "role": [
          "admin"
        ]
      }
    ]
  }
}

Here's my sample code:

SolrClient client = new
CloudSolrClient("zoohost1:2181,zoohost2:2181,zoohost3:2181");
((CloudSolrClient)client).setDefaultCollection(DEFAULT_COLLECTION);
ModifiableSolrParams param = getSearchSolrQuery();
SolrRequest<?> solrRequest = new QueryRequest(param);
solrRequest.setBasicAuthCredentials(USER, PASSWORD);
try{
     for(int j=0;j<20;j++){
NamedList<Object> results = client.request(solrRequest);
      }
}catch(Exception ex){

}

private static ModifiableSolrParams getSearchSolrQuery() {
ModifiableSolrParams solrParams = new ModifiableSolrParams();
solrParams.set("q", "*:*");
solrParams.set("qt","/select");
solrParams.set("rows", "3");
return solrParams;
}

The query sometime returns results, but fails probably half of the time,
there's no pattern though. This is applicable to any request handler
specified in the security.json

Looks like the SolrRequest loses the user/password on the flight.

Here's the exception recieved at SolrJ client:

org.apache.solr.common.SolrException.log(SolrException.java:148) -
org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException: Error
from server at http://xx.xxx.xxx.134:8983/solr/knowledge: Expected mime
type application/octet-stream but got text/html. <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Error 401 Unauthorized request, Response code: 401</title>
</head>
<body><h2>HTTP ERROR 401</h2>
<p>Problem accessing /solr/knowledge/select. Reason:
<pre>    Unauthorized request, Response code:
401</pre></p><hr><i><small>Powered by Jetty://</small></i><hr/>

</body>
</html>

        at
org.apache.solr.client.solrj.impl.HttpSolrClient.executeMethod(HttpSolrClient.java:544)
        at
org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:240)
        at
org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:229)
        at
org.apache.solr.client.solrj.impl.LBHttpSolrClient.doRequest(LBHttpSolrClient.java:372)
        at
org.apache.solr.client.solrj.impl.LBHttpSolrClient.request(LBHttpSolrClient.java:325)
        at
org.apache.solr.handler.component.HttpShardHandlerFactory.makeLoadBalancedRequest(HttpShardHandlerFactory.java:246)
        at
org.apache.solr.handler.component.HttpShardHandler$1.call(HttpShardHandler.java:201)
        at
org.apache.solr.handler.component.HttpShardHandler$1.call(HttpShardHandler.java:163)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at
org.apache.solr.common.util.ExecutorUtil$MDCAwareThreadPoolExecutor$1.run(ExecutorUtil.java:231)
        at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)

I'm using Solr 5.5 with 2 shards having 1 replica each.

I'll really appreciate if someone can let me know what I'm missing here.

Reply via email to