運行Tomcat 7,我試圖在Tomcat服務器上配置/conf/web.xml以保護一些具有基本身份驗證的URL並提供一些其他URL以供公共訪問。Tomcat 7 - 多個安全約束不起作用
將tomcat-users.xml中包含以下角色和用戶:
<role rolename="test-ui"/>
<user username="paul" password="password" roles="test-ui"/>
我加入了以下部分雄貓/conf/web.xml
<security-constraint>
<web-resource-collection>
<web-resource-name>Public access</web-resource-name>
<url-pattern>/docs/*</url-pattern>
</web-resource-collection>
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>Protected access</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>test-ui</role-name>
</auth-constraint>
</security-constraint>
<security-role>
<description>Protected access</description>
<role-name>test-ui</role-name>
</security-role>
<login-config>
<auth-method>BASIC</auth-method>
</login-config>
所以有兩個「安全約束「元素,公共的不包含'auth-constraint',這實際上應該表示沒有必要的認證。
當我打開網址 http://localhost:8080
Tomcat的要求進行身份驗證。 這是好的,但是當我打開網址 http://localhost:8080/docs/
的Tomcat也要求進行身份驗證和我的理解,這是設置爲「非安全」 URL - 如此公開acccess,但它並沒有這樣的表現。
我在配置中出了什麼問題,或者這種情況不應該像這樣工作?
謝謝。 保羅
您是否嘗試將第二個衝突移動到頂端? – home 2012-02-24 16:21:45
謝謝,但是,我試過了。效果是一樣的。沒有身份驗證,我無法訪問/文檔。 – 2012-02-24 16:25:00