【发布时间】:2013-11-11 09:02:22
【问题描述】:
我正在尝试在 IBM WebSphere WAS v8.5 上实现基于表单的身份验证,但由于某些原因,安全配置被忽略,我可以访问所有保护资源而无需重定向到登录页面 下面是我的声明性安全配置
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="3.0" 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">
<display-name>TestSSO</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<security-role>
<role-name>manager</role-name>
</security-role>
<security-constraint>
<web-resource-collection>
<web-resource-name>management pages</web-resource-name>
<url-pattern>/index.html</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>manager</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<form-login-config>
<form-login-page>/login.html</form-login-page>
<form-error-page>/error.html</form-error-page>
</form-login-config>
</login-config>
<?xml version="1.0" encoding="UTF-8"?>
<application-bnd xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://websphere.ibm.com/xml/ns/javaee"
xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-application-bnd_1_0.xsd" version="1.0">
<security-role name="manager">
<special-subject type="ALL_AUTHENTICATED_USERS" />
</security-role>
</application-bnd>
【问题讨论】:
-
服务器是否启用了安全性?
-
在下面看到您的 cmets,这可能意味着您已经通过了身份验证。一个简单的测试是实际写出用户名或类似的东西。这样你就知道你是否通过了身份验证。
-
我尝试使用 chrome 而不是 IE 进行访问,它给了我登录页面,我登录了,一切正常,但我关闭了浏览器重新测试,同样的第一个问题安全被忽略了,我无需身份验证即可访问受保护的资源
-
您可能已经通过操作系统配置了身份验证,该操作系统会在您不知情的情况下自动登录。如果您运行的是 Windows 和 IE,您可能会自动登录(在 WAS 中配置正确),但在 Chrome 中,默认情况下可能未配置。这可以解释您所描述的行为。
-
谢谢丹尼尔,但我怎么知道是否是这种情况(通过操作系统进行身份验证,在你不知情的情况下自动登录),因为如果我重新启动电脑并尝试登录页面只是第一次,然后我又回到了同样的情况“安全被忽略”