How to setup authentication mechanism in solr 7?

十年热恋 提交于 2020-07-22 21:43:29

问题


I have installed solr 7.7 standalone in my production server. I am trying to setup authentication mechanism using jetty approach. This is what I tried:

1.modified “/opt/solr/server/etc/jetty.xml

<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>
  1. created credentials file in /opt/solr/server/etc/realm.properties

    admin: admin123,core
    
  2. modified /opt/solr/server/etc/webdefault.xml

    <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>core</role-name>
     </auth-constraint>
    </security-constraint>
    
    <login-config>
     <auth-method>BASIC</auth-method>
     <realm-name>Test Realm</realm-name>
    </login-config>
    

After this If I restart solr service, solr is not getting started. In the logs I am getting error as:

 Suppressed: java.lang.NoSuchFieldException: refreshInterval
 Suppressed: java.lang.NoSuchFieldException: TYPE
 Suppressed: java.lang.NoSuchMethodException: org.eclipse.jetty.security.HashLoginService.setRefreshInterval(java.lang.String)

回答1:


Create Security file:sudo vim /var/solr/data/security.json

{
"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"}
}}

This will create user called "solr" with password SolrRocks

Then Restart solr service:sudo service solr restart

Verification:http://<ip_address>:8983/solr/admin/authentication



来源:https://stackoverflow.com/questions/55369465/how-to-setup-authentication-mechanism-in-solr-7

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!