Authentication 基于表单的身份验证为8.5

Authentication 基于表单的身份验证为8.5,authentication,websphere,Authentication,Websphere,我试图在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

我试图在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>
这应该是您的ibm-application-bnd.xml文件


您只定义了一个受保护的资源,即/index.html。调整以包括您需要保护的所有资源。

您必须使用WebSphere控制台进行角色映射。将用户组从用户存储库映射到

服务器是否启用了安全性?看到下面的评论,这可能意味着您已经通过了身份验证。一个简单的测试就是写出用户名或类似的东西。这样你就知道你是否通过了身份验证。我试着用chrome而不是IE访问,它给了我登录页面,我登录了,一切正常,但是我关闭了浏览器以重新测试,同样的第一个安全问题被忽略,我可以在不进行身份验证的情况下访问受保护的资源您可能已经通过操作系统配置了身份验证,该操作系统会在您不知情的情况下自动登录。如果您运行的是Windows和IE,您可以在WAS中使用正确的配置自动登录,但在Chrome中,默认情况下可能未配置。这可以解释您描述的行为。谢谢Daniel,但我如何知道这是否是通过操作系统进行的身份验证,该操作系统会在您不知道的情况下自动登录,因为如果我重新启动电脑并尝试登录,我只会第一次获得登录页面,然后我又回到了同一个案例,安全性被忽略了,这只有在有一个名为manager的安全组时才有效。在这种情况下,角色和应该属于该角色的用户之间已经存在映射。我这样做了,现在它给了我HTTP 403 forbidden,而不是将我重定向到登录页面Yes,它显示如果用户经过身份验证但未授权访问资源,将403 forbidden。只有当用户未经身份验证时,它才会重定向到登录页面。所以你们可以在403页上添加自我重定向。但我并没有输入任何凭证,它怎么知道我已通过身份验证?我需要在请求受保护的资源时将用户重定向到登录页面您是否在其他服务器上配置了SSO?
<?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>
<?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">
        <group name="manager" />
     </security-role>

</application-bnd>