我们如何为 websphere 中任何角色的所有经过身份验证的用户(基本身份验证)提供访问权限
how can we provide access for all authenticated users(basic authentication) in websphere for any role
对于 Wildfly,任何经过身份验证的用户都可以通过 web.xml
中的以下更改访问任何受保护的资源
<auth-constraint>
<role-name>*</role-name>
</auth-constraint>
在安全约束中定义安全角色如下
<security-role>
<role-name>*</role-name>
</security-role>
但同样不适用于 Websphere,抛出授权失败异常,要使其在 Websphere Adminconsole 中工作,需要进行以下更改。
- WAS AdminConsole -> 应用程序 > 企业应用程序 -> 单击 .EAR
- 单击安全角色到 user/group 映射
- Select 您希望用于身份验证的角色。(在我的例子中是
*,定义于web.xml)
- 将特殊主题映射到 "All authenticated in Application Realm"
如何跳过管理控制台更改以使其正常工作,或任何其他更好的方法。
对我有用的是我在 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 使用这个来映射到您定义的角色的分组。
希望这对您有所帮助或推动您前进。
为了实现上述目标,即为 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>
以上角色映射将允许所有经过身份验证的用户访问受保护的资源。
对于 Wildfly,任何经过身份验证的用户都可以通过 web.xml
中的以下更改访问任何受保护的资源<auth-constraint>
<role-name>*</role-name>
</auth-constraint>
在安全约束中定义安全角色如下
<security-role>
<role-name>*</role-name>
</security-role>
但同样不适用于 Websphere,抛出授权失败异常,要使其在 Websphere Adminconsole 中工作,需要进行以下更改。
- WAS AdminConsole -> 应用程序 > 企业应用程序 -> 单击 .EAR
- 单击安全角色到 user/group 映射
- Select 您希望用于身份验证的角色。(在我的例子中是 *,定义于web.xml)
- 将特殊主题映射到 "All authenticated in Application Realm"
如何跳过管理控制台更改以使其正常工作,或任何其他更好的方法。
对我有用的是我在 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 使用这个来映射到您定义的角色的分组。
希望这对您有所帮助或推动您前进。
为了实现上述目标,即为 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>
以上角色映射将允许所有经过身份验证的用户访问受保护的资源。