【问题标题】:How to make welcome page unprotected for form based authentication in websphere如何使欢迎页面不受 websphere 中基于表单的身份验证的保护
【发布时间】:2018-01-11 18:49:25
【问题描述】:

我的欢迎屏幕是任何网站的主屏幕(应该是不受保护的资源)。

http://domain:port/myApp 重定向到web.xml 的welcome-file-list 中配置的jsp 文件说welcome.jsp。

但是在点击welcome.jsp 上的任何链接时,这些资源必须受到保护,相应的url 将类似于http://:port/myApp/someRequest

我在部署描述符中使用了以下更改:

<security-constraint>
        <web-resource-collection>
            <url-pattern>/*</url-pattern>
        </web-resource-collection>
        <auth-constraint>
            <role-name>SuperUser</role-name>
        </auth-constraint>
        <user-data-constraint>
            <description>Encryption is not required for the application in general.
            </description>
            <transport-guarantee>NONE</transport-guarantee>
        </user-data-constraint>
</security-constraint>
<security-constraint>
        <web-resource-collection>
            <url-pattern>/styles/*</url-pattern>
            <url-pattern>/welcome.jsp</url-pattern>
        </web-resource-collection>
    </security-constraint>


<login-config>
        <auth-method>FORM</auth-method>
        <realm-name>MyRealm</realm-name>
        <form-login-config>
            <form-login-page>/login.jsp</form-login-page>
            <form-error-page>/loginerror.jsp</form-error-page>
        </form-login-config>
    </login-config>

问题仍然是我的主页,即welcome.jsp 受到保护,应用程序重定向到WebSphere Application 服务器的登录屏幕,但在tomcat 和Wildfly 中工作正常。

如何使 http://:port/myApp 在 WebSphere 中不受保护。

【问题讨论】:

  • 您好,您能否确认它是在您明确指定 URL 中的welcome.jsp (host:port/myApp/welcome.jsp) 还是仅在您访问w/o welcome.jsp (host:port/myApp) 时提示?
  • host:port/myApp/welcome.jsp 工作正常,即无需任何身份验证。

标签: security jakarta-ee websphere web.xml websphere-liberty


【解决方案1】:

在请求被默认 servlet 处理之前,WebContainer 不会确定它是否需要对特定请求使用欢迎页面。当 WebContainer 确定没有映射到该请求的 servlet 时,它会将默认 servlet 设置为目标,然后检查是否需要欢迎页面。在为默认 servlet 提供服务之前,WebContainer 会调用安全检查,这是将请求 URI 与定义的安全约束进行比较的地方。本场景中的请求URI(/myApp)与定义的/*约束匹配,所以会触发认证过程。

这是按设计工作的。为了获得所需的行为,需要使安全约束更加具体,而不仅仅是 /*。一种可能性是将所有打算保护的静态资源保存在单独的目录中,并为该目录定义一个约束,例如 /secured/*。对于 servlet,您可以定义用于安全 servlet 的 servlet 映射模式,并向您的安全配置添加更具体的约束以匹配该模式,类似于上面的静态资源示例。

【讨论】:

  • 以上几点都是正确的,奇怪的是Wildfly和WebSphere在安全方面存在如此大的差异。谢谢@ZRoman
猜你喜欢
  • 2010-12-26
  • 1970-01-01
  • 2011-09-03
  • 1970-01-01
  • 2010-11-19
  • 2018-03-28
  • 2021-10-26
  • 2014-11-20
  • 1970-01-01
相关资源
最近更新 更多