Solr Lucene – Digest Authentication

Solr Lucene – Digest Authentication

This article shows you how to setup the Digest Authentication in Solr Lucene, which comes with Jetty in the examples provided in the download pack available online. Download Solr Download Solr from official solr site, then unpack it to your working directory. You are now ready to start up the Solr server, change to the solr/example and then use the following command to start the server:
java -jar start.jar
Fire the url http://localhost:8983/solr/admin/, and you will see a Solr interface ready to be used! Add digest authentication to the admin interface At this stage, the admin interface is accessible by anyone because there is no login required. We want to add login to it. When you start Solr server the first time, it will extract Jetty server files under solr/work, you can see it from the first three lines of output after starting the server:
2009-05-13 09:27:40.260::INFO:  Logging to STDERR via org.mortbay.log.StdErrLog
2009-05-13 09:27:40.680::INFO:  jetty-6.1.3
2009-05-13 09:27:40.810::INFO:  Extract jar:file:/path/to/solr/example/webapps/solr.war!/ to /path/to/solr/example/work/Jetty_0_0_0_0_8983_solr.war__solr__k1kf17/webapp
We want to modify the Jetty config files to enable the authentication. Change to /path/to/solr/example/work/Jetty_0_0_0_0_8983_solr.war!__solr!__k1kf17/webapp/WEB-INF directory and you will see a file called web.xml. Open this file up using you favourite editor and move to the end of file. Add the following code just before closing tag:


      Solr Admin
      /*


      admin
      user
      moderator




    DIGEST
    SolrRealm

This defines three possible roles can be used: admin, user and moderator, as well as using DIGEST auth method and realm-name of the auth. This realm-name corresponses to the main configuration of Jetty server defined in /path/to/solr/examples//etc/jetty.xml file:

    
    
    
    
    
    
    




            SolrRealm
            /etc/realm.properties




The username and password is set in /path/to/solr/examples/etc/realm.properties file, to create it:
htdigest -c realm.properties "SolrRealm" test
The second parameter “SolrRealm” need to match the one defined in jetty.xml file as mentioned before:
SolrRealm
Follow the prompt to enter password twice then a new entry in the realm.properties will be created as follows:
test:SolrRealm:ddab10a18fd464a50ad1073a6b77e39f
Open it up and update it to:
test: MD5:ddab10a18fd464a50ad1073a6b77e39f,admin
The last word “admin” is the role defined in the web.xml file in the above section, you can change to user or moderator for this instant setup. Finally, restart the Jetty server by pressing Ctrl+C in the shell and re-run the command we used before to start it up:
java -jar start.jar
Be sure to be at the solr root directory to run this command. Now if you refresh your browser which opened Solr admin interface before, you will be prompted to enter the username and password, enter “test” for username and whatever password you entered before and you are in.

2 Comments

Leave a Reply

Your email address will not be published.

My new Snowflake Blog is now live. I will not be updating this blog anymore but will continue with new contents in the Snowflake world!