IBM WAS 忽略了 web.xml 中的安全性

JIV*_*JIV 3 java security websphere web.xml

我有适用于 tomcat web 服务器的 web 应用程序。我想将它迁移到 IBM websphere AS,但我遇到了安全问题。整个应用程序安全性在 web.xml 文件中定义如下:

<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list> 

<security-constraint>
    <web-resource-collection>
        <web-resource-name>Dynamic pages</web-resource-name>
        <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <description>access.</description>
        <role-name>user</role-name>
    </auth-constraint>
</security-constraint>

<login-config id="LoginConfig_1">
    <auth-method>FORM</auth-method>
    <realm-name>SecureRealm</realm-name>
    <form-login-config id="FormLoginConfig_1">
        <form-login-page>/login.jsp</form-login-page>
        <form-error-page>/loginFail.jsp</form-error-page>
    </form-login-config>
</login-config>

<security-role>
    <description>User of the application.</description>
    <role-name>user</role-name>
</security-role> 
Run Code Online (Sandbox Code Playgroud)

Websphere 忽略所有这些安全性,并允许我从 Web 应用程序访问任何页面而无需显示登录页面。如果我手动转到 login.jsp 并将正确的密码输入到应用程序中,但它会失败,getUserPrincipal()因为它返回 null(没有登录)。如果我把错误的密码转发到 loginFail.jsp,也一样。
服务器日志中也没有错误。
我在做什么错或与 tomcat 不同?
感谢帮助。

Ang*_*own 5

可能未启用 WebSphere 安全性。如果不是,您的 web.xml 设置将被忽略。

在管理控制台中,查看安全 -> 全局安全部分。确保选中“启用应用程序安全性”。

请注意,您可以在不同的“级别”(节点、服务器等)创建不同的安全设置。如果您在安全 -> 安全域中定义了多个域,请确保运行您的 web 应用程序的应用服务器具有正确的域集。