Liberty ldap security-role/group 映射不工作
Liberty ldap security-role/group mapping not working
在我的 server.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
groupIDs 是由我的自定义登录模块设置的,因为 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 的授权失败。未授予用户访问任何所需角色的权限:[MyAdmin].
当我更改 server.xml 中的配置以接受用户 memyselfandi 时,我获得了访问权限。因此配置适用于用户而不是组。我也尝试使用 access-id,但这也不起作用(我的 LDAP 领域名为 LdapRegistry)。
在 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=[]}
在 server.xml 中配置用户后,角色映射到用户 user:LdapRegistry/uid=MEMYSELFANDI,ou=person,o=somedir=[MyAdmin]
有什么方法可以测试为什么它不起作用吗?也许是一些 LDAP 配置问题?我可以设置什么来获取所需的日志信息? 目前我登录:
traceSpecification="*=info:com.ibm.ws.security.*=all:com.ibm.websphere.security.*=all:com.ibm.ws.webcontainer.security.*=all:com.ibm.ws.wim.*=all"/>
我想知道在尝试映射组时在后台处理了什么。或者更好的是,我犯的错误导致无法映射或找到组。
经过一些测试,事实证明,当您将组添加到主题时,您必须使用 "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]));
最终的组条目将如下所示:
group:MyLdapRealm/cn=myGroup,ou..
在我的 server.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
groupIDs 是由我的自定义登录模块设置的,因为 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 的授权失败。未授予用户访问任何所需角色的权限:[MyAdmin].
当我更改 server.xml 中的配置以接受用户 memyselfandi 时,我获得了访问权限。因此配置适用于用户而不是组。我也尝试使用 access-id,但这也不起作用(我的 LDAP 领域名为 LdapRegistry)。
在 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=[]}
在 server.xml 中配置用户后,角色映射到用户 user:LdapRegistry/uid=MEMYSELFANDI,ou=person,o=somedir=[MyAdmin]
有什么方法可以测试为什么它不起作用吗?也许是一些 LDAP 配置问题?我可以设置什么来获取所需的日志信息? 目前我登录:
traceSpecification="*=info:com.ibm.ws.security.*=all:com.ibm.websphere.security.*=all:com.ibm.ws.webcontainer.security.*=all:com.ibm.ws.wim.*=all"/>
我想知道在尝试映射组时在后台处理了什么。或者更好的是,我犯的错误导致无法映射或找到组。
经过一些测试,事实证明,当您将组添加到主题时,您必须使用 "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]));
最终的组条目将如下所示:
group:MyLdapRealm/cn=myGroup,ou..