Another_Omeka_User
Another_Omeka_User

Reputation: 51

Setting up basic authentication Solr 5.3.1 for dummies

OK, so I'm not a server guru, but I need to figure out how to set up authentication for our solr server admin page. I'm trying to follow the steps outlined here:

https://lucidworks.com/2015/08/17/securing-solr-basic-auth-permission-rules/

I can't even complete the first step, upload the JSON file. I created the JSON file, but when I go to upload it, I get a "command not found" error when trying to run zkcli.sh. Do I need to set something up with Zookeeper first to get this to run? What should I check?

EDIT: I followed some tutorials online and did the following:

1) set jetty-http.xml to localhost (changing the host to 127.0.0.1) by adding the line:

<Set name="Host"><SystemProperty name="jetty.host" default="127.0.0.1"/></Set>

2) I also added the following to the apache config file (obv changing to correct path in the path to htpasswd):

<Location /solr > 
AuthName "Secure Area" 
AuthType Basic 
AuthUserFile /path/to/htpasswd/.htpasswd require valid-user 
</Location> 
ProxyPass /solr http://localhost:8983/solr 
ProxyPassReverse /solr http://localhost:8983/solr 

3) I set up a password via htpasswd. 4) I restarted the server. I refreshed the solr page and nothing; it's a broken link.

What am I doing wrong?

(Unfortunately every time I do that the solr core also disappears and refuses to load. That's another issue though, which I thought was related to permissions but doesn't seem to be...)

Upvotes: 0

Views: 933

Answers (1)

Code wrangler
Code wrangler

Reputation: 134

You can follow these steps to get the basic authentication work in solr. Assuming you have ubuntu OS and installled the server using the install script.

Step1. sudo vi /opt/solr/server/etc/jetty.xml Add the following code towards the end of the file before the "" tag.

<Call name="addBean">
    <Arg>
        <New class="org.eclipse.jetty.security.HashLoginService">
            <Set name="name">Test Realm</Set>
            <Set name="config"><SystemProperty name="jetty.home" default="."/>/etc/realm.properties</Set>
            <Set name="refreshInterval">0</Set>
        </New>
    </Arg>
</Call>

Step2. sudo vi /opt/solr/server/etc/webdefault.xml Add the following code towards the end of the file before the "" tag.

<security-constraint>
    <web-resource-collection>
        <web-resource-name>Solr authenticated application</web-resource-name>
        <url-pattern>/</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <role-name>core1-role</role-name>
    </auth-constraint>
</security-constraint>

<login-config>
    <auth-method>BASIC</auth-method>
    <realm-name>Test Realm</realm-name>
</login-config>

Step3. Create the file "/opt/solr/server/etc/realm.properties" with the following contents:

USERNAME: PASSWORD,core1-role

The username and password is stored in the following file /opt/solr/server/etc/realm.properties

Upvotes: 0

Related Questions