SCIM API (SYSTEM ONLY)
引入于极狐GitLab 11.10。
SCIM API 实现 RFC7644 协议。由于此 API 被系统用于进行 SCIM 供应商集成,如有更改,恕不另行通知。
要使用此 API,必须为群组启用群组 SSO。 此 API 仅在启用群组 SSO 的 SCIM 的情况下使用。这是创建 SCIM 身份的先决条件。
获取 SCIM 配置用户的列表
此端点用作 SCIM 同步机制的一部分。它只返回基于唯一 ID 的单个用户,该 ID 应与用户的 extern_uid
相匹配。
GET /api/scim/v2/groups/:group_path/Users
参数:
参数 | 类型 | 是否必需 | 描述 |
---|---|---|---|
filter
| string | no | 过滤项表达式 |
group_path
| string | yes | 群组的完整路径 |
startIndex
| integer | no | 从 1 开始的索引,指示从何处开始返回结果。小于 1 的值将被视为 1 |
count
| integer | no | 期望的最大查询结果数 |
分页遵循 SCIM 规格,而不是其他地方所使用的极狐GitLab 分页。如果记录在请求之间发生变化,则页面可能缺少已移动到不同页面的记录或重复先前请求的记录。
请求示例:
curl "https://gitlab.example.com/api/scim/v2/groups/test_group/Users?filter=id%20eq%20%220b1d561c-21ff-4092-beab-8154b17f82f2%22" \
--header "Authorization: Bearer <your_scim_token>" \
--header "Content-Type: application/scim+json"
响应示例:
{
"schemas": [
"urn:ietf:params:scim:api:messages:2.0:ListResponse"
],
"totalResults": 1,
"itemsPerPage": 20,
"startIndex": 1,
"Resources": [
{
"schemas": [
"urn:ietf:params:scim:schemas:core:2.0:User"
],
"id": "0b1d561c-21ff-4092-beab-8154b17f82f2",
"active": true,
"name.formatted": "Test User",
"userName": "username",
"meta": { "resourceType":"User" },
"emails": [
{
"type": "work",
"value": "name@example.com",
"primary": true
}
]
}
]
}
获取单个 SCIM 配置用户
GET /api/scim/v2/groups/:group_path/Users/:id
参数:
参数 | 类型 | 是否必需 | 描述 |
---|---|---|---|
id
| string | yes | 用户的外部 UID |
group_path
| string | yes | 群组的完整路径 |
请求示例:
curl "https://gitlab.example.com/api/scim/v2/groups/test_group/Users/f0b1d561c-21ff-4092-beab-8154b17f82f2" \
--header "Authorization: Bearer <your_scim_token>" --header "Content-Type: application/scim+json"
响应示例:
{
"schemas": [
"urn:ietf:params:scim:schemas:core:2.0:User"
],
"id": "0b1d561c-21ff-4092-beab-8154b17f82f2",
"active": true,
"name.formatted": "Test User",
"userName": "username",
"meta": { "resourceType":"User" },
"emails": [
{
"type": "work",
"value": "name@example.com",
"primary": true
}
]
}
创建 SCIM 配置用户
POST /api/scim/v2/groups/:group_path/Users/
参数:
参数 | 类型 | 是否必需 | 描述 |
---|---|---|---|
externalId
| string | yes | 用户的外部 UID |
userName
| string | yes | 用户的用户名 |
emails
| JSON string | yes | 工作电子邮件 |
name
| JSON string | yes | 用户名称 |
meta
| string | no | 资源类型(User )
|
请求示例:
curl --verbose --request POST "https://gitlab.example.com/api/scim/v2/groups/test_group/Users" \
--data '{"externalId":"test_uid","active":null,"userName":"username","emails":[{"primary":true,"type":"work","value":"name@example.com"}],"name":{"formatted":"Test User","familyName":"User","givenName":"Test"},"schemas":["urn:ietf:params:scim:schemas:core:2.0:User"],"meta":{"resourceType":"User"}}' \
--header "Authorization: Bearer <your_scim_token>" --header "Content-Type: application/scim+json"
响应示例:
{
"schemas": [
"urn:ietf:params:scim:schemas:core:2.0:User"
],
"id": "0b1d561c-21ff-4092-beab-8154b17f82f2",
"active": true,
"name.formatted": "Test User",
"userName": "username",
"meta": { "resourceType":"User" },
"emails": [
{
"type": "work",
"value": "name@example.com",
"primary": true
}
]
}
如果成功,返回 201
状态码。
更新单个 SCIM 配置用户
可以更新的字段为:
SCIM/IdP 字段 | 极狐GitLab 字段 |
---|---|
id/externalId
| extern_uid
|
name.formatted
|
name (已移除)
|
emails\[type eq "work"\].value
|
email (已移除)
|
active
| 如果 active = false ,则移除身份
|
userName
|
username (已移除)
|
PATCH /api/scim/v2/groups/:group_path/Users/:id
参数:
参数 | 类型 | 是否必需 | 描述 |
---|---|---|---|
id
| string | yes | 用户的外部 UID |
group_path
| string | yes | 群组的完整路径 |
Operations
| JSON string | yes | 操作表达式 |
请求示例:
curl --verbose --request PATCH "https://gitlab.example.com/api/scim/v2/groups/test_group/Users/f0b1d561c-21ff-4092-beab-8154b17f82f2" \
--data '{ "Operations": [{"op":"Add","path":"name.formatted","value":"New Name"}] }' \
--header "Authorization: Bearer <your_scim_token>" --header "Content-Type: application/scim+json"
如果成功,返回带有 204
状态码的空响应。
移除单个 SCIM 配置用户
移除用户的 SSO 身份和群组成员资格。
DELETE /api/scim/v2/groups/:group_path/Users/:id
参数:
参数 | 类型 | 是否必需 | 描述 |
---|---|---|---|
id
| string | yes | 用户的外部 UID |
group_path
| string | yes | 群组的完整路径 |
请求示例:
curl --verbose --request DELETE "https://gitlab.example.com/api/scim/v2/groups/test_group/Users/f0b1d561c-21ff-4092-beab-8154b17f82f2" \
--header "Authorization: Bearer <your_scim_token>" --header "Content-Type: application/scim+json"
如果成功,返回带有 204
状态码的空响应。
可用过滤项
它们与 RFC7644 过滤部分中指定的表达式相匹配。
过滤项 | 描述 |
---|---|
eq
| 参数与指定的值完全匹配 |
示例:
id eq a-b-c-d
可用操作
它们进行 RFC7644 更新部分中指定的操作。
运算符 | 描述 |
---|---|
Replace
| 更新参数的值 |
Add
| 参数有新值 |
示例:
{ "op": "Add", "path": "name.formatted", "value": "New Name" }