Liberty 中的 SCIM 操作
跨域身份管理系统 (SCIM) 1.1 规范在 Liberty 中受支持。
检索资源
WebSphere® Application Server Liberty 支持 SCIM 1.1 规范。有关此规范的更多信息,请参阅http://www.simplecloud.info/。
要检索已知资源,必须将 GET 请求发送至所配置 HTTP 端点。请参阅以下示例:/Users/{id} 或 /Groups/{id}。
此外,以下示例显示针对 LDAP 注册表执行的操作:
<ldapRegistry id="LDAP1" realm="SampleLdapIDSRealm" host="9.127.1.90" port="1389" ignoreCase="true"
baseDN="o=ibm,c=us" ldapType="IBM Tivoli Directory Server" searchTimeout="8m" recursiveSearch="true"
bindDN="xxxxxx" bindPassword="xxxxxxx">
<ldapEntityType name="PersonAccount">
<rdnProperty name="uid" objectClass="inetOrgPerson"/>
<objectClass>inetOrgPerson</objectClass>
</ldapEntityType>
<ldapEntityType name="Group">
<objectClass>groupofnames</objectClass>
<objectClass>ibm-nestedGroup</objectClass>
<rdnProperty name="cn" objectClass="groupofnames"/>
</ldapEntityType>
<attributeConfiguration>
<attribute name="title" propertyName="honorificPrefix" syntax="String" entityType="PersonAccount">
</attribute>
<attribute name="initials" propertyName="middleName" syntax="String" entityType="PersonAccount">
</attribute>
<attribute name="st" propertyName="honorificSuffix" syntax="String" entityType="PersonAccount">
</attribute>
<attribute name="l" propertyName="homeStateOrProvinceName" syntax="String" entityType="PersonAccount">
</attribute>
<attribute name="street" propertyName="homeStreet" syntax="String" entityType="PersonAccount">
</attribute>
<attribute name="postalAddress" propertyName="homeCity" syntax="String" entityType="PersonAccount">
</attribute>
<attribute name="postalCode" propertyName="homePostalCode" syntax="String" entityType="PersonAccount">
</attribute>
<attribute name="postOfficeBox" propertyName="homeCountryName" syntax="String" entityType="PersonAccount">
</attribute>
<attribute name="departmentNumber" propertyName="photoURLThumbnail" syntax="String" entityType="PersonAccount">
</attribute>
<attribute name="description" propertyName="photoURL" syntax="String" entityType="PersonAccount">
</attribute>
</attributeConfiguration>
<groupProperties>
<memberAttribute name="member" dummyMember="uid=dummy" objectClass="groupOfNames" scope="direct"/>
<memberAttribute name="ibm-memberGroup" objectClass="ibm-nestedGroup" scope="direct"/>
</groupProperties>
</ldapRegistry>
要从 LDAP 检索资源,必须将 GET 请求作为 https://localhost:9090/ibm/api/scim/Users/uid=jsmith,o=ibm,c=us 发送。
查询资源
要查询资源,必须将 GET 请求发送至所配置 HTTP 端点并指定过滤器以进行搜索。还可指定 attributes 参数以从所返回资源返回值子集,并指定分页和排序参数以组织所返回资源。以下示例显示一些过滤器选项:
- 指定参数以检索值子集:例如,https://localhost:9090/ibm/api/scim/Users?filter=givenname sw "Jo" 检索名称以 Jo 开头的所有用户。
- 指定 attributes 参数以检索值子集:例如,https://localhost:9090/ibm/api/scim/Users?filter=givenname sw "Jo"&attributes=username,emails&filter=name.familyname eq "Smith" 检索名称以 Jo 开头且姓氏为 Smith 的用户名的电子邮件地址。
- 指定分页和排序参数以检索所组织资源。例如,https://localhost:9090/ibm/api/scim/Users?filter=givenname sw "Jo"&attributes=username&sortBy=username&startIndex=3&count=5 检索已排序结果的第三页,其中每页包含 5 个用户名称,这些用户名以 Jo 开头且姓氏为 Smith。
注:
- 底层联合存储库确定过滤器中指定的值是否区分大小写。对于 LDAP,这些值在缺省情况下不区分大小写,除非该属性映射至区分大小写的 LDAP 属性。
- 不能在搜索过滤器中使用用户名。
- 联合不支持 SCIM 属性的基本注册表、SAF 注册表或定制注册表时,将始终针对用户名搜索过滤器模式,并且仅返回用户名属性。
创建资源
要创建新资源,必须将 POST 请求发送至资源端点,即 Users 或 Groups。POST
内容必须包含用户 json 对象,并且 HTTP 标头 content-type 必须设置为 application/json。
注: application/xml
内容类型不受支持。
要创建用户,必须将以下请求发布至 https://localhost:9090/ibm/api/scim/Users
Content-TypeContent-Type: application/json
Content-Length: ...
{
"schemas":["urn:scim:schemas:core:1.0"],
"userName":"jdoe",
"externalId": "uid=jdoe,o=ibm,c=us",
"name":{
"familyName":"Doe",
"givenName":"Jane"
}
}
请求必须包含在用户注册表中成功创建用户或组所需的全部属性。例如,在后端 Tivoli Directory Server LDAP 中,创建用户所需的基本 LDAP 属性集将为 uid、sn 和 cn;所以,任何创建用户的请求必须包含 userName、givenName 和 familyName。如果用户注册表中存在任何模式违例,那么创建操作将失败。
externalId 属性将充当标识,并且必须指定。属性格式依赖于后端用户注册表的规范。在前面的示例中,后端为其 baseEntry 设置为 o=ibm,c=us 的 LDAP 服务器,并且用户的 RDN 属性设置为 UID,所以 externalId 变为 uid=jdoe,o=ibm,c=us。
根据创建请求,将返回所创建用户对象。
{
"schemas":["urn:scim:schemas:core:1.0"],
"id":"uid=jdoe,o=ibm,c=us",
"userName":"jdoe",
"externalId":"uid=jdoe,o=ibm,c=us",
"name":{
"formatted":"Jane Doe",
"familyName":"Doe",
"givenName":"Jane"
},
"meta":{
"lastModified":"2015-09-15T14:30:11", "location":"https:\\localhost:9090\ibm\api\scim\Users\uid=jdoe,o=ibm,c=us",
"created":"2015-09-15T14:30:11"
}
}
如果配置了多个 LDAP 并且需要调用创建操作,那么必须对实体定义缺省父代。所定义父代指定将在其下创建新实体的基本条目。以下示例显示
PersonAccount 的缺省父代的配置。
<federatedRepository>
<primaryRealm name="WIMRegistry">
<participatingBaseEntry name="o=ibm,c=us"/>
<participatingBaseEntry name="o=ldap"/>
</primaryRealm>
<supportedEntityType>
<defaultParent>o=ldap</defaultParent>
<name>PersonAccount</name>
</supportedEntityType>
</federatedRepository>
修改资源
要修改资源,您需要将 PUT 请求发送至资源端点,即 /Users 或 /Groups。PUT
请求执行资源的完整更新。输入中未指定的任何属性将被删除。
注: 使用 PATCH 进行的部分更新不受支持。
要修改先前创建的资源,必须将以下请求发布至 https://localhost:9090/ibm/api/scim/Users/uid=jdoe,o=ibm,c=us。
Content-Type: application/json
Content-Length: ...
{
"schemas":["urn:scim:schemas:core:1.0"],
"userName":"jdoe",
"externalId":"uid=jdoe,o=ibm,c=us",
"name":{
"familyName":"Doe",
"givenName":"Janet"
}
}
此请求将对象的名字从 Jane 修改为 Janet。URL 中指定的标识必须与用户对象中指定的 externalId 匹配。要修改组 cn=employeeGroup,o=ibm,c=us 并更改组成员资格,需要指定成员属性。
Content-Type: application/json
Content-Length: ...
{
"id":"cn=employeeGroup,o=ibm,c=us",
"schemas":["urn:scim:schemas:core:1.0"],
"displayName":"employeeGroup",
"externalId":"cn=employeeGroup,o=ibm,c=us",
"members":[{"value":"uid=jdoe,o=ibm,c=us", "type":"User"},{"value":"cn=consultants,o=ibm,c=us", "type":"Group"}]
}
要修改组 cn=employeeGroup,o=ibm,c=us 并移除组中的所有成员,需要指定空成员属性。
Content-Type: application/json
Content-Length: ...
{
"id":"cn=employeeGroup,o=ibm,c=us",
"schemas":["urn:scim:schemas:core:1.0"],
"displayName":"employeeGroup",
"externalId":"cn=employeeGroup,o=ibm,c=us",
"members":[]
}
删除资源
要删除资源,需要将 DELETE 请求发送至资源端点,即 /Users 或 /Groups。例如,要删除先前示例中创建的用户 uid=jdoe,o=ibm,c=us,请将请求发送至 https://localhost:9090/ibm/api/scim/Users/uid=jdoe,o=ibm,c=us注: SCIM 仅在 Java 7 或更高版本上运行。