【问题标题】:how can we provide access for all authenticated users(basic authentication) in websphere for any role我们如何为 websphere 中所有经过身份验证的用户(基本身份验证)提供任何角色的访问权限
【发布时间】:2017-06-22 03:31:51
【问题描述】:

对于 Wildfly,任何经过身份验证的用户都可以通过 web.xml 中的以下更改访问任何受保护的资源

<auth-constraint>
        <role-name>*</role-name>
</auth-constraint>

在安全约束中定义安全角色如下

<security-role>
    <role-name>*</role-name>
</security-role>

但同样不适用于 Websphere,抛出授权失败异常,使其在 Websphere Adminconsole 中的更改下工作。

  1. WAS AdminConsole -> 应用程序 > 企业应用程序 -> 单击 .EAR
  2. 单击安全角色到用户/组的映射
  3. 选择您希望用于身份验证的角色。(在我的例子中是 *,在 web.xml 中定义)
  4. 将特殊主题映射到“所有在应用程序领域中进行身份验证”

如何跳过管理控制台更改以使其正常工作,或任何其他更好的方法。

【问题讨论】:

    标签: authentication jakarta-ee authorization websphere wildfly


    【解决方案1】:

    对我有用的是我在 web.xml 中定义了 ff:

    <security-role>
      role1
    </security-role>
    
    <security-role>
      role2
    </security-role>
    
         <security-constraint>
            <display-name>All Authenticated</display-name>
            <web-resource-collection>
                <web-resource-name>
                    All Authenticated Pages
                </web-resource-name>
                <url-pattern>/webpage.xhtml</url-pattern> 
            </web-resource-collection>
            <auth-constraint>
                <role-name>role1</role-name>
                <role-name>role2</role-name> 
            </auth-constraint>
        </security-constraint>
    

    本质上,这定义了角色,然后是页面的单独定义以及将被允许访问它的角色。

    然后我还在我的 EAR 文件中定义了一个 ibm-application-bnd.xml,如下所示:

    <?xml version="1.0" encoding="UTF-8"?>
    <application-bnd
        xmlns="http://websphere.ibm.com/xml/ns/javaee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-application-bnd_1_2.xsd"
        version="1.2">
    
        <security-role name="role1">
            <group name="role1" />
        </security-role>
        <security-role name="role2">
            <group name="role2" />
        </security-role> 
    </application-bnd>
    

    我认为 WebSphere 使用这个来映射到它对您定义的角色的分组。

    希望这对您有所帮助或推动您前进。

    【讨论】:

      【解决方案2】:

      为了实现上述目标,即对 WebSphere 中所有经过身份验证的用户进行授权,请创建一个逻辑角色[无需创建任何物理组],在 web.xml 中说“AllAuthneticated”并将其作为授权约束。

       <auth-constraint>
            <role-name>AllAuthneticated</role-name>
       </auth-constraint>
      
      
      <security-role>
          <role-name>AllAuthneticated</role-name>
      </security-role>
      

      然后在EAR文件中定义一个ibm-application-bnd.xml如下:

      <security-role name="AllAuthneticated">
               <special-subject type="ALL_AUTHENTICATED_USERS" />
      </security-role>
      

      上述角色映射将允许所有经过身份验证的用户访问受保护的资源。

      【讨论】:

        猜你喜欢
        • 2010-10-07
        • 2017-09-11
        • 1970-01-01
        • 2019-06-28
        • 1970-01-01
        • 2017-12-24
        • 1970-01-01
        • 2010-09-21
        • 2016-01-15
        相关资源
        最近更新 更多