我運行了Tomcat 7.0.52服務器。在它有一個文件瀏覽器(http://www.vonloesch.de/filebrowser.html它有點舊,但它做我需要它做的)Tomcat JSP身份驗證失敗
但是,我想密碼保護瀏覽器,並沒有存儲密碼作爲純文本,所以我已經更新了境界部分如下:
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
digest="SHA-1" digestEncoding="UTF-8"
resourceName="UserDatabase"/>
文件瀏覽器安裝在$ {CATALINA_HOME} /webapps/Browser/index.jsp
然後,我創建的文件$ {CATALINA_HOME}/webapps /目錄瀏覽器/ WEB-INF /web.xml如下:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>Browser</display-name>
<description>A JSP file manager for Tomcat</description>
<!-- Security roles referenced by this web application -->
<security-role>
<role-name>browser</role-name>
</security-role>
<!-- Define a Security Constraint on this Application -->
<!-- NOTE: None of these roles are present in the default users file -->
<security-constraint>
<web-resource-collection>
<web-resource-name>Browser</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>browser</role-name>
</auth-constraint>
</security-constraint>
<!-- Define the Login Configuration for this Application -->
<login-config>
<auth-method>BASIC</auth-method>
</login-config>
</web-app>
最後,我添加了以下行部分在$ {CATALINA_HOME} /conf/tomcat-users.xml文件:
<role rolename="browser"/>
<user username="fadmin" password="...pw hash removed..." roles="browser"/>
的tomcat-users.xml文件還包含用於訪問信息Tomcat經理頁面。此外,我已經檢查了我針對Tomcat管理器的web.xml創建的web.xml,並且這些部分看起來非常相似
現在,當我訪問Tomcat管理器頁面時,我得到一個用戶名/密碼框,以及何時我輸入了正確的憑證,我可以訪問管理員頁面。然而,當我嘗試訪問的瀏覽器頁面,我沒有得到的用戶名/密碼框,但我立即得到一個403頁,內容如下:
HTTP Status 403 - Access to the requested resource has been denied
--------------------------------------------------------------------------------
type Status report
message Access to the requested resource has been denied
description Access to the specified resource has been forbidden.
我在做什麼錯?
根據要求,這裏是tomcat-users.xml文件(我做了,雖然離開了意見和刪除密碼哈希)
<tomcat-users>
<role rolename="tomcat"/>
<role rolename="admin-gui"/>
<role rolename="manager-gui"/>
<role rolename="manager-status"/>
<user username="tcadmin" password="...pw hash removed..." roles="tomcat,admin-gui,manager-gui,manager-status"/>
<role rolename="browser"/>
<user username="fadmin" password="...pw hash removed..." roles="browser"/>
</tomcat-users>
請提供tomcat-users.xml文件的完整內容(您仍然可以隱藏散列)。 –
@MarkThomas,我在原始文章的底部添加了tomcat-users.xml文件的內容。 –
要求提供完整文件的一點是,默認情況下,所有用戶都被註釋掉,並且人們經常會錯過這一點。現在你已經刪除了我們無法檢查是否有問題的評論。 –