我正在测试 openliberty 功能 SAML Web 单点登录 2.0 (https://openliberty.io/docs/latest/reference/feature/samlWeb-2.0.html)。
与我的 IdP 的集成可以很好地进行身份验证,但我无法使其适用于角色/组映射(我收到 403 禁止访问错误)。
此功能在我的 server.xml 配置文件中定义如下:
<samlWebSso20 id="defaultSP" nameIDFormat="email" userIdentifier="cn" groupIdentifier="memberOf" mapToUserRegistry="No" authFilterRef="myAuthFilter"/>
安全约束定义如下:
<application location="guide-getting-started.war" type="war" id="guide-getting-started.war" name="ctxrt-saml-test" contextRoot="ctxrt-saml-test">
<application-bnd>
<security-role name="XXXX_admin_view">
<group name="XXXX_admin_view" />
</security-role>
</application-bnd>
</application>
在我的网络应用程序中,我有以下安全约束:
<security-constraint>
<web-resource-collection>
<url-pattern>/*</url-pattern>
<http-method>GET</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>XXXX_admin_view</role-name>
</auth-constraint>
</security-constraint>
来自我的 IdP 的 SAML 响应包含以下内容:
SAML2.0 Response
[...]
SAML 2.0 AttributeStatement
uid xxxxxxx
memberOf CN=XXXX_admin_view,OU=XXXX,OU=Applications,OU=Groups,DC=[xxxx],DC=fr
cn xxxxx
在我的 Openliberty 服务器日志中,我看到以下内容:
Added the following subject to role mapping for application: ctxrt-saml-test.
group:[IdP-realmName]/CN=XXXX_admin_view,OU=XXXX,OU=Applications,OU=Groups,DC=[xxxx],DC=fr
和
CWWKS9104A: Authorization failed for user [user_cn] while invoking ctxrt-saml-test on /. The user is not granted access to any of the required roles: [XXXX_admin_view].
看起来 SP 级别 (openliberty) 定义的角色与 SAML 响应中 IdP 返回的组之间的映射不起作用...
由于我还无法更改 IdP SAML 响应,因此我已尝试了 SP 级别配置的所有组合,但似乎都不起作用...
角色 = [IdP-realmName]/CN=XXXX_admin_view,OU=XXXX,OU=应用程序,OU=组,DC=[xxxx],DC=fr 或者 角色 = CN=XXXX_admin_view、OU=XXXX、OU=应用程序、OU=组、DC=[xxxx]、DC=fr 或者 角色 = XXXX_admin_view
非常感谢任何帮助
谢谢
我和同事解决了这个问题。
解决方案是在“group”元素中指定一个access-id,如下所示:
<security-role name="XXXX_admin_view">
<group access-id="group:[IdP-realmName]/CN=XXXX_admin_view,OU=XXXX,OU=Applications,OU=Groups,DC=[xxxx],DC=fr" />
</security-role>
请参阅:github.com/OpenLiberty/open-liberty/issues/17096