当前位置: 首页 > 知识库问答 >
问题:

Liberty ldap安全角色/组映射无法工作

翟浩穰
2023-03-14

在我的服务器中。xml我有以下配置:

<enterpriseApplication location="myApp.ear" name="myApp" id="myapp" autoStart="true">
    <classloader commonLibraryRef="global" apiTypeVisibility="spec, ibm-api, api, third-party"/>
    <application-bnd >
        <security-role name="MyAdmin">
            <group name="App.Admin"/>
            <group name="cn=App.Admin,ou=ent,ou=App,ou=apps,o=somedir"/>
            <!--user name="memyselfandi"/-->
            <!--group name="App.Admin" access-id="group:LdapRegistry/cn=App.Admin,ou=ent,ou=App,ou=apps,o=somedir"/-->
        </security-role>
    </application-bnd>
</enterpriseApplication>

认证后我的主题是这样的:

    Principal: WSPrincipal:uid=MEMYSELFANDI,ou=person,o=somedir
    Public Credential: com.ibm.ws.security.credentials.wscred.WSCredentialImpl@b29eac,
        realmName=LdapRegistry,
        securityName=MEMYSELFANDI,
        realmSecurityName=LdapRegistry/MEMYSELFANDI,
        uniqueSecurityName=uid=MEMYSELFANDI,ou=person,o=somedir,
        primaryGroupId=null,
        accessId=user:LdapRegistry/uid=MEMYSELFANDI,ou=person,o=somedir,
        groupIds=[SomeOtherGroups, App.Admin]
    Private Credential: CustomLoginModuleCredential
    Private Credential: com.ibm.ws.security.token.internal.SingleSignonTokenImpl@7c2ff51c

组 ID 是由我的自定义登录模块设置的,因为 ldap 注册表中的组在具有成员的属性中没有条目,因此不是由标准 Liberty 登录模块设置的。因此,在我的自定义模块中,我在LDAP中搜索用户,并将条目的组添加到私有凭据的groupIds数组中:

WSCredential credential = (WSCredential) _sharedState.get(com.ibm.wsspi.security.
                auth.callback.Constants.WSCREDENTIAL_KEY);
String[] grpList = ldapEntry.getAttribute("myEntGrps").getValues();
[..]
credential.getGroupIds().add(grpList[i]);

我还需要做些什么吗?或者只需要将组的字符串添加到数组中就足够了?

我还尝试使用securityGroupName(例如cn=myGroup,ou=...)而不仅仅是组名(例如myGroup)。

什么是正确的格式?

完成所有这些操作后,当我调用受保护的 servlet 时,我会收到错误消息:

CWWKS9104A:在 / 上调用 myApp 时,用户 uid = MEMYSELFANDI、ou=person、o=somedir 的授权失败。用户未被授予对任何所需角色的访问权限:[我的管理员]。

当我在服务器中更改配置.xml接受用户 memyselfandi 时,我将获得访问权限。因此,该配置适用于用户,但不适用于组。我也尝试过使用访问 ID,但这也不起作用(我的 LDAP 领域名为 Ldap 注册)。

在trace.log我看到以下内容(我猜日志条目被Liberty截断):

 ppbnd.internal.authorization.AppBndAuthorizationTableService 3 Added the following subject to role mapping for application: myApp.
    App.Admin
    []
[..]
< updateMapsForAccessId Exit
    {user:LdapRegistry/uid=MEMYSELFANDI,ou=person,o=somedir=[],App.Admin=[]}

服务器中配置了用户。xml,角色映射到用户user:LdapRegistry/uid=MEMYSELFANDI,ou=person,o=somedir=[MyAdmin]

有没有办法测试它为什么不工作?也许是一些LDAP配置问题?我可以设置什么来获取所需的日志信息?目前我记录:

< code > trace specification = " * = info:com . IBM . ws . security . * = all:com . IBM . WebSphere . security . * = all:com . IBM . ws . web container . security . * = all:com . IBM . ws . WIM . * = all "/

我想知道在尝试映射组时在后台处理的内容。或者更好的是,我犯的错误导致无法映射或找到组。

共有1个答案

令狐嘉运
2023-03-14

经过一些测试,结果是,当您将组添加到主题时,您必须使用“access-id”格式。

这就是我的登录模块现在所做的:

WSCredential credential = (WSCredential) _sharedState.get(com.ibm.wsspi.security.
            auth.callback.Constants.WSCREDENTIAL_KEY);
UserRegistry registry = RegistryHelper.getUserRegistry(credential.getRealmName());
String[] grpList = ldapEntry.getAttribute("myEntGrps").getValues();
[..]
  credential.getGroupIds().add("group:"+credential.getRealmName()+"/"+registry.getGroupSecurityName(grpList[i]));

最终,组条目将如下所示:

组:MyLdapRealm/cn=myGroup,ou..

 类似资料:
  • 我无法在注释中使用方法。还有给出。我错过了什么?尽管工作正常。 我正在从数据库中为用户分配权限。

  • 我有一个用KeyCloak保护的spring boot应用程序。领域中的每个用户都有我的资源(客户机)的角色。角色配置在用户选项卡上,对于角色映射选项卡下的特定用户,角色配置为客户端角色: 我还使用了与LDAP Active Directory的集成,所有用户都来自LDAP Active Directory。现在,如果我想为Active Directory(AD)组添加特定的角色,我必须进入Act

  • 我们公司的用户存储在ldap(oracle internet目录)中。用户有特定的组,例如管理员、用户等。我需要将这些组映射到我的客户端应用程序角色。客户机应用程序是带有keycloak-spring-security-adapter(pom)的测试Spring Boot应用程序。 我在Keycloak管理控制台中执行的步骤: 在Users Federation菜单中使用ldap创建用户Feder

  • 在代码中使用XSLT 2.0的字符映射功能时,我遇到了以下错误。 名称空间中的元素“样式表”http://www.w3.org/1999/XSL/Transform'命名空间中的子元素'character map'无效'http://www.w3.org/1999/XSL/Transform“是的 这是我的XSLT声明 请提供有关如何在XSLT中使用字符映射的帮助。

  • 我有自由配置文件身份验证与MS活动目录。但是我无法设置到组的角色映射。 我已在web.xml中创建了安全角色: 我用wmm将角色映射到ibm-application-bnd.xml中的一个组,该组工作: 但这并不适用于自由档案 我需要更改访问id吗?

  • 我的Spring Security性有问题,因为当我登录到这个站点时,我无法通过角色admin访问url。这是我的安全配置 我试图与hasRole, hasAuthure, hasAny权威,但不工作,只有工作许可所有,但我不想访问的东西url用户与角色用户 这是我的登录控制器 我在数据库中有两个用户,一个是角色管理员,第二个是角色用户,但这不起作用,有人能解释为什么吗? https://gith