zoukankan      html  css  js  c++  java
  • solr基于jetty容器配置后台登陆角色用户名密码

    solr版本4.0.0

    我的solr下载后解压在d盘,你的随意。

    在D:apache-solr-4.0.0apache-solr-4.0.0exampleetc目录下新建role.properties文件,名字可随便。

    内容如下:

    #  
    # 这个文件定义用户名,密码和角色
    #  
    # 格式如下  
    #  <username>: <password>[,<rolename> ...]  
    #  
    #userName: password,role  
    test: 123,admin

    编辑D:apache-solr-4.0.0apache-solr-4.0.0examplecontextssolr.xml文件如下,文件中插入安全处理程序设置标签

    <?xml version="1.0"?>
    <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
    <Configure class="org.eclipse.jetty.webapp.WebAppContext">
      <Set name="contextPath">/solr</Set>
      <Set name="war"><SystemProperty name="jetty.home"/>/webapps/solr.war</Set>
      <Set name="defaultsDescriptor"><SystemProperty name="jetty.home"/>/etc/webdefault.xml</Set>
      <Set name="tempDirectory"><Property name="jetty.home" default="."/>/solr-webapp</Set>
      <!-- 安全处理程序设置 -->  
      <Get name="securityHandler">  
             <Set name="loginService">  
                     <New class="org.eclipse.jetty.security.HashLoginService">  
                             <Set name="name">TestRealm</Set>  <!-- 一个名字-->
                  <!-- 引入刚刚新建的文件 --> <Set name="config"><SystemProperty name="jetty.home" default="."/>/etc/realm.properties</Set> </New> </Set> </Get> </Configure>

    编辑D:apache-solr-4.0.0apache-solr-4.0.0examplesolr-webappwebappWEB-INFweb.xml文件,插入

    <security-constraint>    
      <web-resource-collection>    
          <web-resource-name>Solr</web-resource-name> <!--描述-->   
          <url-pattern>/</url-pattern>               <!-- 验证的网页的位置-->    
        </web-resource-collection>    
         <auth-constraint>    
            <role-name>admin</role-name>   <!-- 验证的角色,别写成用户名,如有多个角色可以写多个role-name 标签-->    
         </auth-constraint>    
     </security-constraint>    
     <login-config>    
            <auth-method>BASIC</auth-method>            <!-- 关键-->    
            <realm-name>TestRealm</realm-name> 
    </login-config>

    配置完成后,重启solr服务器,重新访问solr就需要用户名和密码了

    可参考http://www.mossle.com/docs/auth/html/ch109-preauth.html

  • 相关阅读:
    BZOJ 1036 树的统计 | 树链剖分模板题
    BZOJ 3295 动态逆序对 | CDQ分治
    Luogu 3810 & BZOJ 3262 陌上花开/三维偏序 | CDQ分治
    BZOJ 2152 聪聪可可 | 树的点分治
    BZOJ 2458 最小三角形 | 平面分治
    51nod 1564 区间的价值 | 分治 尺取法
    Luogu 1429 平面最近点对 | 平面分治
    Codeforces 633C Spy Syndrome 2 | Trie树裸题
    一棵简单能用的左偏树
    【网络流24题】餐巾计划(图解)
  • 原文地址:https://www.cnblogs.com/hihtml5/p/5775896.html
Copyright © 2011-2022 走看看