2012-03-16 70 views
1

我有一個Web應用程序設置爲在每個輸入點提示輸入用戶名和密碼。除了一個名爲showStatus的URL之外,一切都需要基本身份驗證,其目的是顯示應用程序的狀態。 showStatus URL不需要認證。問題是,即使訪問showStatus URL,密碼對話框仍然顯示。我可以點擊取消,或者點擊確定,仍然可以訪問該頁面,但我想知道如何禁用showSession URL的對話框。Glassfish 3.1登錄域不應提示輸入特定URL的憑據

這裏是web.xml內容:

<!-- constraint for restricted pages --> 
<security-constraint> 
    <display-name>restricted access</display-name> 
    <web-resource-collection> 
     <web-resource-name>Secure Pages</web-resource-name> 
     <description/> 
     <url-pattern>/*</url-pattern> 
    </web-resource-collection> 
    <auth-constraint> 
     <description/> 
     <role-name>USERS</role-name> 
    </auth-constraint> 
</security-constraint> 

<!-- do not require authentication for showStatus URL --> 
<security-constraint> 
    <web-resource-collection> 
     <web-resource-name>ShowStatus</web-resource-name> 
     <url-pattern>/showStatus.action</url-pattern> 
     <http-method>GET</http-method> 
    </web-resource-collection> 
</security-constraint> 

<!-- need the login prompt to appear for everything but showStatus --> 
<login-config> 
    <auth-method>BASIC</auth-method> 
    <realm-name>MYREALM</realm-name> 
</login-config> 

<security-role> 
    <role-name>USERS</role-name> 
</security-role> 
+0

我仍無法解決此問題。誰能幫忙? – gsjava 2012-03-20 13:24:43

+0

回到你自己的步驟,你可能在配置中也限制了該頁面。也許這個鏈接可以幫助你: http://javing.blogspot.in/2012/05/here-in-this-video-you-can-see-how-i.html – sfrj 2012-05-01 23:27:49

回答

0

最有可能你有你的showStatus網頁上的一些受保護的資源。密碼對話框在您的頁面嘗試訪問此資源時顯示,因爲它們也由faces servlet提供服務。

當您加載showStatus頁面時,您可以通過使用螢火蟲或一些嵌入式工具監控瀏覽器中的網絡活動來檢查需要哪些資源。你會看到這樣的事情:

enter image description here

所有這一切需要的是這種資源的網址添加到<web-resource-collection>不需要認證。或者,您可以通過添加以下模式授予對所有資源的開放訪問權限:

<url-pattern>/faces/javax.faces.resource/*</url-pattern> 
相關問題