【问题标题】:how to bypass through Java EE security roles如何绕过 Java EE 安全角色
【发布时间】:2011-02-10 11:40:51
【问题描述】:

这是我的 web.xml 中的示例代码

<security-constraint>
    <display-name>
    change password</display-name>
    <web-resource-collection>
        <web-resource-name>change password</web-resource-name>
        <url-pattern>/ResetPassword.html</url-pattern>
        <http-method>GET</http-method>
        <http-method>POST</http-method>
    </web-resource-collection>
    <auth-constraint>
        <description>Roles which can access landing page</description>
        <role-name>Admin</role-name>
    </auth-constraint>
    <user-data-constraint>
        <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
</security-constraint> 

只有具有“Admin”角色的用户才能访问“ResetPassword.html”页面。

有一个 Java EE API 可以让我们测试当前用户是否可以访问特定角色。

request.isUserInRole("Admin");

我的默认用户“DefUser”返回 false,因为他没有分配角色,并且我收到 403 错误,因为 DefUser 无法访问“ResetPassword.html”页面。如果我使用 DefUser 登录,我可以让 request.isUserInRole("Admin") 返回 true 吗?还有其他方法吗?

我确实想使用安全约束。这是可能存在像“DefUser”这样的用户的要求之一,该用户应该有权访问所有没有分配角色的页面。

我只想绕过这些安全限制。 “DefUser”有没有办法访问“ResetPassword.html”页面?

http://www.imrantariq.com/blog/

【问题讨论】:

    标签: java jakarta-ee security


    【解决方案1】:

    Java EE 安全不能被绕过。 否则,它会像巧克力茶壶一样有用。

    【讨论】:

      【解决方案2】:

      将您的应用程序部署到应用程序服务器。 转到应用程序服务器的管理并将您的 DefUser 分配给角色 Admin。 如果您有其他角色,请将您的 DefUser 也分配给这些角色。

      你去。无需旁路。

      【讨论】:

        【解决方案3】:

        不确定 web.xml,但至少在 EJB 上有安全注释,如果我没记错的话,您可以将每个服务配置为可访问:

        • 任何用户
        • 任何经过身份验证的用户
        • 按特定角色

        【讨论】:

          猜你喜欢
          • 2011-05-14
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2013-09-08
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多