Securing Apache Solr with Kerberos

What is Apache Solr?

Apache Solr is an open source search platform developed upon a Java library described Lucene. Solr is a kind of full-text search server that uses the Lucene Java search library for searching full text at its core. Solr having REST(representational state transfer) feature like HTTP/XML and JSON API’s that helps in linking it to most programming languages. Many of the Internet’s most significant sites like Apple, CISCO, etc. use Apache Solr for their search and navigation features. In actual we can say that Apache Solr is sub-branch of Apache Lucene that is developed with Java. As part of the Lucene project, Solr uses the Lucene Java search library at its core for searching and indexing.This article will cover details regarding Apache Solr Security.

Operations Performed by Apache Solr to Search a document –

Indexing – The Document that needs to be searched is converted into the machine-readable format that is termed as indexing.

Quering – Than it tries to understand the terms of Query that is asked by the user like some essential terms, keywords, etc.

Mapping – The QQuery made by the user is then mapped to the document stored in the database for the relevant result.

Ranking the Outcome – Whenever the engine searches the indexed text, it lists the output based on there relevance.

Apache Solr Security Architecture

Indexing and searching are the two primary functions that need to be supported by Apache Solr. There are Handlers present that is used to handle data within a specific category. Update processor chain took place whenever data is uploaded. It goes through the cleanup process in which duplicate values are eliminated to avoid unnecessary reappearing.

Examining the field and generation of the tokens is done by the Analyzer. The field data is broken into lexical units or symbols by the help of Tokenizer. There can only be one Tokenizer per Analyzer. Common words like is, am, are, etc. Are taken out by the Apache Solr Administration for more effective result.

Now there is also Query Parser that is responsible for the parsing of the Query. DisMax,Lucene,e-DisMax etc. Are some of the Query Parsers. Based on the requirements, each Parser comes to the play as each Parser has different roles. After passing the Query, it is then handed over to index searcher. The job of the index reader is to run the queries on the index store and gather the results to the response editor. The response writer is responsible for responding to the client; it formats the query response based on the search results from the Lucene engine. Following Diagram will show us the process after Search is done.

Apache Solr Security with Kerberos

The Solar client that need to authenticate with the Solar is necessary for safety point of view. In the case of Kerberos, Authentication Solr includes Kerberos service principal and keytab file that will be needed to authenticate with Zookeeper and between the nodes of The Solr Cluster. Besides this, all the clients and users will also be having a valid ticket that will be needed before sending a request to Solr.

To secure Apache Solr, we will walk through the following steps –

Before configuring Solr, we will make sure that we have Kerberos Service Principle for each of the Solr Host and there is also Zookeeper that must be available in KDC server. We will then generate a Keytab file as –

Assuming hostname to be and home directory to be home/foo/. For this particular environment, the phase will be –

root@kdc:/# kadmin.local
Authenticating as principal foo/admin@EXAMPLE.COM with password

kadmin.local:  addprinc HTTP/
WARNING: no policy specified for HTTP/; defaulting to no policy
Enter the password for principal "HTTP/":
Re-enter password for principal "HTTP/":
Principal "HTTP/" created.

kadmin.local:  ktadd -k /tmp/120.keytab HTTP/
Entry for principal HTTP/ with kvno 2, encryption type aes256-cts-hmac-sha1-96 added to keytab WRFILE:/tmp/120.keytab.
Entry for principal HTTP/ with kvno 2, encryption type arcfour-hmac added to keytab WRFILE:/tmp/120.keytab.
Entry for principal HTTP/ with kvno 2, encryption type des3-cbc-sha1 added to keytab WRFILE:/tmp/108.keytab.
Entry for principal HTTP/ with kvno 2, encryption type des-cbc-crc added to keytab WRFILE:/tmp/120.keytab.

kadmin.local:  quit

Copy the keytab file from the KDC server’s/tmp/120.keytab location to the Solr host at /keytabs/120.keytab. Repeat this step for each Solr node.If in case the Zookeeper hasn’t been set up than similar steps must take place for the ZooKeeper service principal and keytab.

Now we have to create the security.json file and we have to put in our $SOLR_HOME directory. In case of SolrCloud mode we can upload it by using Kerberos Plugin into Zookeeper. While we can create it as follow –

server/scripts/cloud-scripts/ -zkhost localhost:2181 -cmd put /security.json  
'{"authentication":{"class": ""}}'

Now we have to Define a JAAS Configuration File. This helps us to define specific properties that will be needed for authentication. We can also set some other properties like ticket caching etc.

Below is the JAAS configuration file with the name and path of /home/foo/jaas-client.conf

Client { required

This name and path will be used to define the Solr start parameters and helps in authentication of the internode requests and to zookeeper requests.

Now before Starting the Solr, some parameters need to be passed. We can also use passe these parameters at the command line with the bin/solr start command. Following table tells us the settings that are needed or not.

Once the Configuration is completed, we can start the Solr by the following command –

bin/solr -c -z server1:2181,server2:2181,server3:2181/solr

To test the Configuration, we will try to connect the Solr with the following command as –

curl --negotiate -u :""

A Comprehensive Approach

Real Time Indexing and Advanced Text Search features can help Enterprises to enable highly scalable and fault tolerant indexing capabilities. To know more about Near Real-Time Indexing we advise taking the following steps –

Leave a Comment

Name required.
Enter a Valid Email Address.
Comment required.(Min 30 Char)

[wpforms id="7646"]
<div class="wpforms-container wpforms-container-full optin-monster-forms" id="wpforms-7646"><form id="wpforms-form-7646" class="wpforms-validate wpforms-form" data-formid="7646" method="post" enctype="multipart/form-data" action="/blog/apache-solr-security/"><noscript class="wpforms-error-noscript">Please enable JavaScript in your browser to complete this form.</noscript><div class="wpforms-page-indicator progress" data-indicator="progress" data-indicator-color="#72b239" data-scroll="1"><span class="wpforms-page-indicator-page-title" ></span><span class="wpforms-page-indicator-page-title-sep" style="display:none;"> - </span><span class="wpforms-page-indicator-steps">Step <span class="wpforms-page-indicator-steps-current">1</span> of 2</span><div class="wpforms-page-indicator-page-progress-wrap"><div class="wpforms-page-indicator-page-progress" style="width:50%;background-color:#72b239;"></div></div></div><div class="wpforms-field-container"><div class="wpforms-page wpforms-page-1 "><div id="wpforms-7646-field_10-container" class="wpforms-field wpforms-field-pagebreak" data-field-id="10"></div><div id="wpforms-7646-field_24-container" class="wpforms-field wpforms-field-html form-popup-header-wrapper" data-field-id="24"><div id="wpforms-7646-field_24"><div class="form-popup-header"> <h2>Accelerate Digital Transformation with Intelligent Automation</h2> </div></div></div><div id="wpforms-7646-field_21-container" class="wpforms-field wpforms-field-radio custom-radio-btn-wrapper wpforms-list-2-columns" data-field-id="21"><label class="wpforms-field-label wpforms-label-hide" for="wpforms-7646-field_21">Sevices <span class="wpforms-required-label">*</span></label><ul id="wpforms-7646-field_21" class="wpforms-field-required wpforms-image-choices wpforms-image-choices-modern"><li class="choice-1 depth-1 wpforms-image-choices-item"><label class="wpforms-field-label-inline" for="wpforms-7646-field_21_1" tabindex="0"><span class="wpforms-image-choices-image"><img src="" alt="Real Time Data Analytics" title="Real Time Data Analytics"></span><input type="radio" id="wpforms-7646-field_21_1" class="wpforms-screen-reader-element" name="wpforms[fields][21]" value="Real Time Data Analytics" tabindex="-1" required ><span class="wpforms-image-choices-label">Real Time Data Analytics</span></label></li><li class="choice-2 depth-1 wpforms-image-choices-item"><label class="wpforms-field-label-inline" for="wpforms-7646-field_21_2" tabindex="0"><span class="wpforms-image-choices-image"><img src="" alt="Interactive Data Visualisation" title="Interactive Data Visualisation"></span><input type="radio" id="wpforms-7646-field_21_2" class="wpforms-screen-reader-element" name="wpforms[fields][21]" value="Interactive Data Visualisation" tabindex="-1" required ><span class="wpforms-image-choices-label">Interactive Data Visualisation</span></label></li><li class="choice-3 depth-1 wpforms-image-choices-item"><label class="wpforms-field-label-inline" for="wpforms-7646-field_21_3" tabindex="0"><span class="wpforms-image-choices-image"><img src="" alt="Application Modernisation" title="Application Modernisation"></span><input type="radio" id="wpforms-7646-field_21_3" class="wpforms-screen-reader-element" name="wpforms[fields][21]" value="Application Modernisation" tabindex="-1" required ><span class="wpforms-image-choices-label">Application Modernisation</span></label></li><li class="choice-4 depth-1 wpforms-image-choices-item"><label class="wpforms-field-label-inline" for="wpforms-7646-field_21_4" tabindex="0"><span class="wpforms-image-choices-image"><img src="" alt="Enterprise AI" title="Enterprise AI"></span><input type="radio" id="wpforms-7646-field_21_4" class="wpforms-screen-reader-element" name="wpforms[fields][21]" value="Enterprise AI" tabindex="-1" required ><span class="wpforms-image-choices-label">Enterprise AI</span></label></li><li class="choice-5 depth-1 wpforms-image-choices-item"><label class="wpforms-field-label-inline" for="wpforms-7646-field_21_5" tabindex="0"><span class="wpforms-image-choices-image"><img src="" alt="Intelligent and Cognitive Automation" title="Intelligent and Cognitive Automation"></span><input type="radio" id="wpforms-7646-field_21_5" class="wpforms-screen-reader-element" name="wpforms[fields][21]" value="Intelligent and Cognitive Automation" tabindex="-1" required ><span class="wpforms-image-choices-label">Intelligent and Cognitive Automation</span></label></li></ul></div><div id="wpforms-7646-field_23-container" class="wpforms-field wpforms-field-pagebreak" data-field-id="23"><div class="wpforms-clear wpforms-pagebreak-left"><button class="wpforms-page-button wpforms-page-next" data-action="next" data-page="1" data-formid="7646">Next</button></div></div></div><div class="wpforms-page wpforms-page-2 last " style="display:none;"><div id="wpforms-7646-field_25-container" class="wpforms-field wpforms-field-html form-popup-header-wrapper" data-field-id="25"><div id="wpforms-7646-field_25"><div class="form-popup-header"> <h2>How can we get in Touch</h2> <p>Fill the form and we will revert back to you soon.<p> </div></div></div><div id="wpforms-7646-field_20-container" class="wpforms-field wpforms-field-name col-12 col-sm-12 col-md-12 form-group" data-field-id="20"><label class="wpforms-field-label" for="wpforms-7646-field_20">Name <span class="wpforms-required-label">*</span></label><input type="text" id="wpforms-7646-field_20" class="wpforms-field-large wpforms-field-required" name="wpforms[fields][20]" placeholder="Name" required></div><div id="wpforms-7646-field_2-container" class="wpforms-field wpforms-field-email col-12 col-sm-12 col-md-12 form-group" data-field-id="2"><label class="wpforms-field-label" for="wpforms-7646-field_2">Email <span class="wpforms-required-label">*</span></label><input type="email" id="wpforms-7646-field_2" class="wpforms-field-large wpforms-field-required" name="wpforms[fields][2]" placeholder="Email" required></div><div id="wpforms-7646-field_3-container" class="wpforms-field wpforms-field-text col-12 col-sm-12 col-md-12 form-group" data-field-id="3"><label class="wpforms-field-label" for="wpforms-7646-field_3">Organization <span class="wpforms-required-label">*</span></label><input type="text" id="wpforms-7646-field_3" class="wpforms-field-large wpforms-field-required" name="wpforms[fields][3]" placeholder="Organization" required></div><div id="wpforms-7646-field_11-container" class="wpforms-field wpforms-field-pagebreak" data-field-id="11"><div class="wpforms-clear wpforms-pagebreak-left"></div></div></div></div><div class="wpforms-field wpforms-field-hp"><label for="wpforms-7646-field-hp" class="wpforms-field-label">Email</label><input type="text" name="wpforms[hp]" id="wpforms-7646-field-hp" class="wpforms-field-medium"></div><input type="hidden" name="wpforms[recaptcha]" value=""><div class="wpforms-submit-container" style="display:none;"><input type="hidden" name="wpforms[id]" value="7646"><input type="hidden" name="wpforms[author]" value="3"><input type="hidden" name="wpforms[post_id]" value="2961"><button type="submit" name="wpforms[submit]" class="wpforms-submit om-trigger-conversion mon-btn" id="wpforms-submit-7646" value="wpforms-submit" aria-live="assertive" data-alt-text="Submitting..." data-submit-text="Submit">Submit</button></div></form></div> <!-- .wpforms-container -->
[wpforms id="1328"]
<div class="wpforms-container wpforms-container-full subscription-form optin-monster-forms" id="wpforms-1328"><form id="wpforms-form-1328" class="wpforms-validate wpforms-form" data-formid="1328" method="post" enctype="multipart/form-data" action="/blog/apache-solr-security/"><noscript class="wpforms-error-noscript">Please enable JavaScript in your browser to complete this form.</noscript><div class="wpforms-field-container"><div id="wpforms-1328-field_1-container" class="wpforms-field wpforms-field-email col-12 col-sm-12 col-md-12 form-group" data-field-id="1"><label class="wpforms-field-label wpforms-label-hide" for="wpforms-1328-field_1">Email <span class="wpforms-required-label">*</span></label><input type="email" id="wpforms-1328-field_1" class="wpforms-field-large wpforms-field-required" name="wpforms[fields][1]" placeholder="Email address" required></div><div id="wpforms-1328-field_8-container" class="wpforms-field wpforms-field-hidden" data-field-id="8"><input type="hidden" id="wpforms-1328-field_8" name="wpforms[fields][8]" value="Subscribe"></div></div><div class="wpforms-field wpforms-field-hp"><label for="wpforms-1328-field-hp" class="wpforms-field-label">Email</label><input type="text" name="wpforms[hp]" id="wpforms-1328-field-hp" class="wpforms-field-medium"></div><input type="hidden" name="wpforms[recaptcha]" value=""><div class="wpforms-submit-container" ><input type="hidden" name="wpforms[id]" value="1328"><input type="hidden" name="wpforms[author]" value="3"><input type="hidden" name="wpforms[post_id]" value="2961"><button type="submit" name="wpforms[submit]" class="wpforms-submit om-trigger-conversion btn" id="wpforms-submit-1328" value="wpforms-submit" aria-live="assertive" data-alt-text="Sending..." data-submit-text="Subscribe">Subscribe</button></div></form></div> <!-- .wpforms-container -->