Java Liberty ldap安全角色/组映射不工作
在my server.xml中,我有以下配置:Java Liberty ldap安全角色/组映射不工作,java,web-services,security,ldap,websphere-liberty,Java,Web Services,Security,Ldap,Websphere Liberty,在my server.xml中,我有以下配置: <enterpriseApplication location="myApp.ear" name="myApp" id="myapp" autoStart="true"> <classloader commonLibraryRef="global" apiTypeVisibility="spec, ibm-api, api, third-party"/> <application-bnd >
<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>
groupid是由我的自定义登录模块设置的,因为ldap注册表中的组在属性中没有包含成员的条目,因此不是由标准Liberty登录模块设置的。因此,在我的自定义模块中,我在LDAP中搜索用户,并将条目组添加到私有凭据的GroupId数组中:
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的授权失败。未授予用户访问任何必需角色的权限:[MyAdmin]
当我在server.xml中更改配置以接受用户memyselfandi时,我获得了访问权限。因此,该配置适用于用户,但不适用于组。我还尝试使用访问id,但这也不起作用(我的LDAP领域名为LdapRegistry)
在trace.log中,我看到以下内容(我猜日志条目被Liberty截断):
ppbnd.internal.authorization.AppBndAuthorizationTableService 3为应用程序的角色映射添加了以下主题:myApp。
应用程序管理员
[]
[..]
在server.xml中配置用户后,角色将映射到用户user:LdapRegistry/uid=MEMYSELFANDI,ou=person,o=somedir=[MyAdmin]
是否有办法测试它为什么不起作用?可能是LDAP配置问题?我可以设置什么来获取所需的日志信息?当前我记录:
traspecification=“*=info:com.ibm.ws.security.*=all:com.ibm.websphere.security.*=all:com.ibm.ws.webcontainer.security.*=all:com.ibm.ws.wim.*=all”/>
我想知道在尝试映射组时,后台处理的是什么。或者更好的是,我所犯的错误导致无法映射或找到组。经过一些测试,结果表明,当您将组添加到主题时,您必须使用“访问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]));
最后,组条目将如下所示:
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
group:MyLdapRealm/cn=myGroup,ou..
尝试使用group:[realm]/[groupname]更新groupId列表。例如,它可能看起来像groupIds=[group:LdapRegistry/App.Admin]。来这里发布我的发现并查看您的回复。你的建议就是解决办法。
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]));