hykd

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

首先,编辑 安装目录下的 /server/contexts/solr-jetty-context.xml 文件:

在 </config> 标签前加入:

<!-- security handler setting -->  
  <Get name="securityHandler">  
         <Set name="loginService">  
                 <New class="org.eclipse.jetty.security.HashLoginService">  
                         <Set name="name">Test Reaml</Set>  
                        <Set name="config"><SystemProperty name="jetty.home" default="."/>/etc/realm.properties</Set>  
                 </New>  
         </Set>  
  </Get>  

/server/etc/目录下:新建文件realm.properties

#  
# This file defines users passwords and roles for a HashUserRealm  
#  
# The format is  
#  <username>: <password>[,<rolename> ...]  
#  
#plain: plain,user  
admin: password,admin  

编辑  /server/solr-webapp/webapp/WEB-INF/web.xml

<security-constraint>  
        <web-resource-collection>  
                <web-resource-name>solr</web-resource-name>  
                <url-pattern>/admin/*</url-pattern>  
        </web-resource-collection>  
        <auth-constraint>  
                <role-name>admin</role-name>  
        </auth-constraint>  
</security-constraint>  
  
<login-config>  
        <auth-method>BASIC</auth-method>  
        <realm-name>Test Realm</realm-name>  
</login-config> 

重启服务,就达到想要的功能了

posted on 2017-03-17 20:40  hykd  阅读(279)  评论(0编辑  收藏  举报