2012-03-16 60 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>