Enabling Basic Authentication in Solr

Enable Basic Authentication in Solr to restrict access to your Solr environment.

Before you begin

The version of the eperi sEcure Platform is 19.4.1.0 or higher.

Procedure

  1. Connect to one of the Solr nodes and change to the root user, if this is not already the case:
    sudo su -
  2. Change to the directory /opt/solr/server/solr:
    cd /opt/solr/server/solr
  3. Create a file named security.json:
    nano security.json
  4. Paste the following content into the file:
    {
    "authentication":{
       "blockUnknown": true,
       "class":"solr.BasicAuthPlugin",
       "credentials":{"solr":"IV0EHq1OnNrj6gvRCwvFwTrZ1+z1oBbnQdiVC3otuq0=Ndd7LKvVBAaZIF0QAVi1ekCfAJXr1GGfLtRUXhgrF8c="}
    },
    "authorization":{
       "class":"solr.RuleBasedAuthorizationPlugin",
       "permissions":[{"name":"security-edit",
          "role":"admin"}],
       "user-role":{"solr":"admin"}
    }}
  5. Save and exit the file.
  6. Upload the security.json file to ZooKeeper (replace the bold marked characters with the actual values):
    /opt/solr/server/scripts/cloud-scripts/zkcli.sh -zkhost zookeeper-hostname:zookeeper-port \
    -cmd putfile /security.json /opt/solr/server/solr/security.json
  7. Use the set-user command of the Solr Authentication API to change the password (replace the bold marked characters with the actual values):
    curl -E solrClientCert.pem --key solrClientKey.pem --insecure --user solr:SolrRocks \
    https://solr-hostname:solr-port/solr/admin/authentication -H 'Content-type:application/\
    json' -d '{"set-user": {"solr" : "yourPassword"}}'
  8. Edit the solr.in.sh file:
    nano /etc/default/solr.in.sh
  9. Uncomment the following lines in the solr.in.sh file and replace the default password with your own password:
    #SOLR_AUTH_TYPE="basic"
    #SOLR_AUTHENTICATION_OPTS="-Dbasicauth=solr:yourPassword"
  10. Repeat the steps 8 and 9 on all other Solr nodes.
  11. Restart the Solr service on all nodes:
    For Ubuntu:
    systemctl restart solr
    For RHEL:
    service solr restart

Results

You have successfully enabled Basic Authentication on all Solr nodes. Additional information about this Solr feature is available in the Apache Solr Reference Guide.