【发布时间】:2015-02-04 06:31:11
【问题描述】:
我正在使用 jetty 在 SOLR 管理面板上应用身份验证。我已经阅读了很多教程并使用以下步骤实现:
在 /solr/core/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="."/>/var/www/solr/core/etc/realm.properties</Set>
<Set name="refreshInterval">0</Set>
</New>
</Arg>
</Call>
在 /solr/core/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>Test Realm</realm-name>
</login-config>
然后使用以下代码行在 solr/core/etc 中创建文件 realm.proprerties 文件:
admin: OBF:1y0s1v1p1v2p1y0y, admin
但是当我使用 URL http://localhost:8983/solr/ 打开 solr 管理面板时。我有一个弹出窗口询问用户名和密码。我填写了在 realm.properties 中添加的用户名和密码。但无法登录。
请帮我找出我错在哪里。
【问题讨论】:
-
将相对路径而不是绝对路径放入
<SystemProperty name="jetty.home" default="."/>...</Set>为我解决了这个问题。