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
-
Connect to one of the Solr nodes and change to the root user, if this is not
already the case:
-
Change to the directory /opt/solr/server/solr:
-
Create a file named security.json:
-
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"}
}}
-
Save and exit the file.
-
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
-
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"}}'
-
Edit the solr.in.sh file:
nano /etc/default/solr.in.sh
-
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"
-
Repeat the steps 8 and 9 on all other Solr nodes.
-
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.