7中设置身份验证机制

7中设置身份验证机制

本文介绍了如何在Solr 7中设置身份验证机制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我已经在生产服务器中独立安装了solr 7.7.我正在尝试使用码头方式设置身份验证机制.这是我尝试过的:

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

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. 在/opt/solr/server/etc/realm.properties中创建的凭证文件

  1. created credentials file in /opt/solr/server/etc/realm.properties

admin: admin123,core

  • 修改了/opt/solr/server/etc/webdefault.xml

  • 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>
    

  • 此后,如果我重新启动solr服务,则说明solr无法启动.在日志中,我收到以下错误消息:

    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)
    

    推荐答案

    创建安全文件: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"}
    }}
    

    这将创建一个名为Solr的用户,其密码为SolrRocks

    This will create user called "solr" with password SolrRocks

    然后重新启动solr服务:sudo service solr restart

    Then Restart solr service:sudo service solr restart

    验证:http://<ip_address>:8983/solr/admin/authentication

    这篇关于如何在Solr 7中设置身份验证机制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

    1403页,肝出来的..

    09-06 17:16