Solr
  1. Solr
  2. SOLR-5960

Add Support for Basic Authentication to Post.jar

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 4.7
    • Fix Version/s: 4.8, 6.0
    • Component/s: scripts and tools
    • Labels:
      None

      Description

      Post.jar currently doesn't support Basic Authentication if Solr is configured to use Basic Authentication.

      I've attached a patch that enables users to use post.jar if their Solr is configured with Basic Authentication.

      Here's the example usage:

      java -Durl="http://username:password@hostname:8080/solr/update" -jar post.jar sample.xml

      1. solr-5960.patch
        2 kB
        Sameer Maggon
      2. solr-5960-1.patch
        2 kB
        Sameer Maggon

        Activity

        Hide
        Sameer Maggon added a comment -

        Patch to support Basic Authentication

        Show
        Sameer Maggon added a comment - Patch to support Basic Authentication
        Hide
        Uwe Schindler added a comment -

        Your patch has several problems:

        • We are not allowed to use private Sun APIs, our build system won't allow this. One public API that could be used and introduces no external dependencies: http://docs.oracle.com/javase/7/docs/api/javax/xml/bind/DatatypeConverter.html
        • You are getting the bytes of the string without specifying a charset, so it depends on default encoding. Please specify StandardCharsets.US_ASCII here (because basic auth credentials must be encoded using that charset).
        Show
        Uwe Schindler added a comment - Your patch has several problems: We are not allowed to use private Sun APIs, our build system won't allow this. One public API that could be used and introduces no external dependencies: http://docs.oracle.com/javase/7/docs/api/javax/xml/bind/DatatypeConverter.html You are getting the bytes of the string without specifying a charset, so it depends on default encoding. Please specify StandardCharsets.US_ASCII here (because basic auth credentials must be encoded using that charset).
        Hide
        Sameer Maggon added a comment -

        Thanks Uwe Schindler for the feedback. I've updated the patch with both those changes & tested them in my environment.

        Show
        Sameer Maggon added a comment - Thanks Uwe Schindler for the feedback. I've updated the patch with both those changes & tested them in my environment.
        Hide
        Uwe Schindler added a comment -

        Thanks for the quick patch! I will check if we can add a testcase for that. I am not sure what needs to be done to set this up (there is already a test for SimplePostTool).

        Show
        Uwe Schindler added a comment - Thanks for the quick patch! I will check if we can add a testcase for that. I am not sure what needs to be done to set this up (there is already a test for SimplePostTool).
        Hide
        ASF subversion and git services added a comment -

        Commit 1585057 from uschindler@apache.org in branch 'dev/trunk'
        [ https://svn.apache.org/r1585057 ]

        SOLR-5960: Add support for basic authentication in post.jar tool

        Show
        ASF subversion and git services added a comment - Commit 1585057 from uschindler@apache.org in branch 'dev/trunk' [ https://svn.apache.org/r1585057 ] SOLR-5960 : Add support for basic authentication in post.jar tool
        Hide
        ASF subversion and git services added a comment -

        Commit 1585062 from uschindler@apache.org in branch 'dev/branches/branch_4x'
        [ https://svn.apache.org/r1585062 ]

        Merged revision(s) 1585057 from lucene/dev/trunk:
        SOLR-5960: Add support for basic authentication in post.jar tool

        Show
        ASF subversion and git services added a comment - Commit 1585062 from uschindler@apache.org in branch 'dev/branches/branch_4x' [ https://svn.apache.org/r1585062 ] Merged revision(s) 1585057 from lucene/dev/trunk: SOLR-5960 : Add support for basic authentication in post.jar tool
        Hide
        Uwe Schindler added a comment -

        I commmited your patch, I just added a simple test for the URL parsing to SimplePostToolTest.

        Unfortunately the whole tool has no real test case, it just uses a "mock mode" where it does nothing.

        To setup a real test we would need to spawn a Jetty and configure it to use basic auth. I cannot do this at the moment, so I just leave this as "untested code".

        Show
        Uwe Schindler added a comment - I commmited your patch, I just added a simple test for the URL parsing to SimplePostToolTest. Unfortunately the whole tool has no real test case, it just uses a "mock mode" where it does nothing. To setup a real test we would need to spawn a Jetty and configure it to use basic auth. I cannot do this at the moment, so I just leave this as "untested code".
        Hide
        Sameer Maggon added a comment -

        Thanks Uwe Schindler, yes that's what I realized when I saw the code that it's primarily Mock Page Fetcher.

        Show
        Sameer Maggon added a comment - Thanks Uwe Schindler , yes that's what I realized when I saw the code that it's primarily Mock Page Fetcher.
        Hide
        Uwe Schindler added a comment -

        Close issue after release of 4.8.0

        Show
        Uwe Schindler added a comment - Close issue after release of 4.8.0

          People

          • Assignee:
            Uwe Schindler
            Reporter:
            Sameer Maggon
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development