【问题标题】:why am I getting "Error 403: AuthorizationFailed" in this simple WebSphere example web.xml?为什么在这个简单的 WebSphere 示例 web.xml 中出现“错误 403:AuthorizationFailed”?
【发布时间】:2012-05-22 17:26:48
【问题描述】:

我正在使用 WebSphere 7。我有一个使用 web.xml 设置的简单示例,如下所示。

这是我测试它的方式:

  1. 我从 WebSphere 中没有用户和组开始

  2. 我尝试访问页面 (/restricted/topsecret.html) 我被提示登录。我不能。

  3. 我使用 WebSphere 管理控制台添加了用户/密码“rob/password”。我现在可以登录,但看不到页面。我收到“403:授权失败”错误。

  4. 我添加了一个名为“ROLE1”的组,并使用 WebSphere 管理控制台将该组分配给用户“rob”。我重启了firefox,我仍然可以登录,但我仍然收到“403”错误。

  5. 我写了一个小JSP(如下)来输出登录的用户名,但即使登录后用户名仍然为空。

知道我做错了什么吗?谢谢!

罗伯

<security-constraint>
  <web-resource-collection>
    <web-resource-name>page test 1</web-resource-name>
    <url-pattern>/restricted/topsecret.html</url-pattern>
    <http-method>GET</http-method>
    <http-method>POST</http-method>
  </web-resource-collection>
  <auth-constraint>
    <role-name>ROLE1</role-name>
  </auth-constraint>
  <user-data-constraint>
    <transport-guarantee>NONE</transport-guarantee>
  </user-data-constraint>
</security-constraint>

usertest.jsp

<%@ page session="true" %>
Logged in username = '<%= request.getRemoteUser() %>' // is always null
<p/>
Logged in username = '<%= request.getUserPrincipal() %>' // is always null

【问题讨论】:

    标签: java authentication websphere web.xml


    【解决方案1】:

    共有三个安全级别

    1. 管理级别
    2. 应用级别
    3. Java 2 级

    我假设您已打开应用程序级别(听起来您已打开但我想检查一下)

    usertest.jsp 是否安全?

    您在将角色映射到用户后是否重新启动了应用程序?

    JSP 中的代码(第一行在语法上看起来不太好。我假设是错字)

    【讨论】:

    • 管理和应用程序级别已打开。 Java 2 级别已关闭。是对的吗?不,usertest.jsp 不安全;我在登录安全页面后尝试访问它。是的,我在添加角色后重新启动了应用程序。是的,一个错字,已更正,谢谢。
    • 仅供参考,我发现了一个不同的(相关)问题。我发布了一个关注它的新问题,这是链接 - 如果可以,请提供帮助,谢谢! -- stackoverflow.com/questions/10725362/…
    【解决方案2】:

    这是针对 WAS 7 的。我最近遇到了这个问题,我们的应用程序抛出 403 错误。

     ibm-application-bnd.xml
    <security-role name="DefaultRole">
            <special-subject type="ALL_AUTHENTICATED_USERS" /></security-role>
        <security-role name="NoSecurity">
            <special-subject type="EVERYONE" /></security-role></application-bnd>
    

    应用程序.xml

    <security-role>
        <role-name>DefaultRole</role-name>
      </security-role>
      <security-role>
        <role-name>NoSecurity</role-name>
      </security-role>
    

    检查两个 xml 文件

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-02-11
      • 1970-01-01
      • 1970-01-01
      • 2017-06-05
      • 2015-04-17
      • 2011-03-03
      • 2018-02-23
      相关资源
      最近更新 更多