Some of the documentation in the Solr wiki is outdated, so here's what worked for me. In the following files, you can change the highlighted fields.
Edit /opt/solr/etc/jetty.xml and add the following:
<Configure>
<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>
...
</Configure>
Edit /opt/solr/solr-webapp/webapp/WEB-INF/web.xml and add the following:
<web-app>
...
<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>
...
</web-app>
Create a file in /opt/solr/etc/realm.properties and put the following in it:
admin: yourPasswordHere,core1-role
You can change "admin" to whatever username you want.
For the password, you can either use the literal password, or use an OBF/MD5/CRYPT hash. To create a hash, you can do the following:
cd /opt/solr
java -cp /lib/jetty-util-8.1.10.v20130312.jar org.eclipse.jetty.util.security.Password admin yourPasswordHere
The above utility will print out the hash to the screen, and you can chose either the OBF, MD5, or CRYPT line. Make sure that you copy the entire line, including the "OBF:..." part. Copy this line to the /opt/solr/etc/realm.properties file; the result will look something like this:
admin: OBF:1x1v1xmk1w9b1pyh1oq31uum1xtv1zej1zer1xtn1uvk1or71pw51w8f1xmq1x0r
,core1-role
The above is all in one line. No line break. Make sure you put the comma before the "core1-role".
After you've changed everything, restart the solr server. If you're using Fedora, do this:
sudo /sbin/service jetty.sh restart
Then open up your web browser to http://localhost:8983/solr/#/collection1/query and the web browser should ask you for a password. Enter admin for the user name and yourPasswordHere for the password.
Hint: if you get an error on the Solr admin webpage, you can check the log for warning messages. The log file is here: /opt/solr/logs/solr.log
More info: