如何保护Solr 5.3.1仅管理页面

god*_*azy 14 security solr jetty

我对Solr很新,我在过去一天半研究这个问题,最后转到这里.

我有一个Solr服务器启动并运行,我让我的网络管理员在防火墙中配置规则,以便我们可以从我的JavaScript应用程序访问它.这有效.我的问题是Solr管理页面是完全对世界开放的,我已经尝试了各种帖子中描述的所有内容,但ZooKeeper方法除外,我真的不想尝试因为我对设置不感兴趣ZooKeeper和SolrCloud.

参考文章:http: //muddyazian.blogspot.com/2013/11/how-to-require-password-authentication.html和其他一些

我所做的是修改的jetty.xml的/ opt/Solr的/服务器/等,并将此

<Call name="addBean">
  <Arg>
    <New class="org.eclipse.jetty.security.HashLoginService">
      <Set name="name">Solr Admin Access</Set>
      <Set name="config"><SystemProperty name="jetty.home" default="."/>/etc/realm.properties</Set>
      <Set name="refreshInterval">0</Set>
    </New>
  </Arg>
</Call>
Run Code Online (Sandbox Code Playgroud)

然后我在/ opt/solr/server/solr-webapp/webapp/WEB-INF中添加到web.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>admin</role-name>
    </auth-constraint>
  </security-constraint>

  <login-config>
    <auth-method>BASIC</auth-method>
    <realm-name>Solr Admin Access</realm-name>

  </login-config>
Run Code Online (Sandbox Code Playgroud)

然后我根据这篇帖子Jetty/SOLR管理面板密码创建了一个realm.properties文件哈希 密码

Solr现在是安全的,但一切都受密码保护,我希望我的查询是开放的,其余的都受到保护.我尝试添加不同的url模式,如/ admin/*,/ mycollection/dataimport/*等,但这些似乎都不会影响查询也是安全的事实.参考https://gist.github.com/jstrassburg/9777027

che*_*ffe 5

按照从 web.xml 的安全约束中排除 JSP的建议,您可以保持配置不变,但公开您希望公开可用的端点。

因此,您可以将<security-constraint>这样的内容添加到您的web.xml中,但忽略<auth-constraint>匹配的<url-pattern>. 这将使其向公众开放。除了 Solr 实例其余部分的基本身份验证之外,您还可以逐步公开应公开的核心或处理程序。

<security-constraint>
  <web-resource-collection>
    <web-resource-name>mycollection</web-resource-name>
    <url-pattern>/mycollection/*</url-pattern>
  </web-resource-collection>
</security-constraint>
Run Code Online (Sandbox Code Playgroud)

需要注意的是,您需要添加任何应作为自己的 URL 模式公开的内容。但这也可能是一个优点,因为您可以选择对集合进行细粒度的访问控制 - 例如每个集合一个用户。