Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-10530

Basic Authentication Plugin blockUnknown HTTP ERROR 401 require authentication

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 6.4.2
    • None
    • None
    • None
    • linux and mac os

    Description

      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 :
      11:20:42.450 [http-bio-8060-exec-10] 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_shard1_replica1: 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_shard1_replica1/update. Reason:
      <pre> require authentication</pre></p>
      </body>
      </html>
      , retry? 0

      please help me find out where I am wrong ! thanks

      Attachments

        1. screenshot-1.png
          86 kB
          wangyongxin

        Issue Links

          Activity

            People

              Unassigned Unassigned
              wangyongxin wangyongxin
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 24h
                  24h
                  Remaining:
                  Remaining Estimate - 24h
                  24h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified