lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "wangyongxin (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (SOLR-10530) Basic Authentication Plugin blockUnknown HTTP ERROR 401 require authentication
Date Fri, 21 Apr 2017 02:12:04 GMT

    [ https://issues.apache.org/jira/browse/SOLR-10530?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15977947#comment-15977947
] 

wangyongxin edited comment on SOLR-10530 at 4/21/17 2:11 AM:
-------------------------------------------------------------

thanks for your comment ,  is there any demo code for me ? and my  solr cloud instance create
by these codes : 
 CloudSolrClient cloudSolrClient = new CloudSolrClient.Builder().withZkHost(zkHostString).build();
        cloudSolrClient.setParser(new XMLResponseParser());
        cloudSolrClient.setDefaultCollection(news_collection);


was (Author: wangyongxin):
thanks for your comment ,  is there any demo code for me ? 

> Basic Authentication Plugin blockUnknown HTTP ERROR 401 require authentication
> ------------------------------------------------------------------------------
>
>                 Key: SOLR-10530
>                 URL: https://issues.apache.org/jira/browse/SOLR-10530
>             Project: Solr
>          Issue Type: Bug
>      Security Level: Public(Default Security Level. Issues are Public) 
>    Affects Versions: 6.4.2
>         Environment: linux  and mac os
>            Reporter: wangyongxin
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> when solr cloud use Basic Authentication Plugin, and set blockUnknown = true, set username
and password in security.json and solr.in.sh,  and my solr version is 6.4.2, and i created
a collection named "news", changed managed-schema and solrconfig.xml in zookeeper cloud, and
add a jar named ik-analyzer.jar into solr webapp lib directory, restart solr clouds, everything
seems ok, and I use my java web project connected to zookeepers, use codes method like :
> public static QueryResponse getResponseWithAuth(CloudSolrClient solr, SolrQuery query)
throws SolrServerException, IOException {
>         QueryRequest req = new QueryRequest(query);
>         req.setBasicAuthCredentials(username, password);
>         return req.process(solr);
>     }
> search in solr with base authentication is working right ! but when I trying to delete
or update documents with solr like this:
> public static UpdateResponse deleteWithAuth(CloudSolrClient solr, String id) throws SolrServerException,
IOException {
>         UpdateRequest updateRequest = new UpdateRequest();
>         updateRequest.setBasicAuthCredentials(username, password);
>         updateRequest.setAction(UpdateRequest.ACTION.COMMIT, false, false);
>         updateRequest.deleteById(id);
>         return updateRequest.process(solr);
>     }
> or update method :
> public static UpdateResponse addWithAuth(CloudSolrClient solr, SolrInputDocument doc)
throws SolrServerException, IOException {
>         UpdateRequest updateRequest = new UpdateRequest();
>         updateRequest.setBasicAuthCredentials(username, password);
>         updateRequest.setAction(UpdateRequest.ACTION.OPTIMIZE, false, false);
>         updateRequest.add(doc);
>         return updateRequest.process(solr);
>     }
>  it returns error like this :
> 22:07:54.335 [http-bio-8031-exec-1] ERROR o.a.s.c.s.i.CloudSolrClient - Request to collection
news failed due to (401) org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException:
Error from server at http://192.168.10.250:8983/solr/news: Expected mime type application/xml
but got text/html. <html>
> <head>
> <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
> <title>Error 401 require authentication</title>
> </head>
> <body><h2>HTTP ERROR 401</h2>
> <p>Problem accessing /solr/news/select. Reason:
> <pre>    require authentication</pre></p>
> </body>
> </html>
> , retry? 0
> please help me find out where I am wrong ! thanks



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Mime
View raw message