用户组与访问授权
维护用户组、组成员和访问授权;写操作需要 `full` 令牌。 本页完整列出 14 个受支持操作的请求与响应契约。
路径均相对于 https://<nsd-host>。先设置 NSD_BASE_URL=https://<nsd-host>/api/v1 和 NSD_TOKEN;示例 ID 与数据均为虚构值。
列出用户组
GET/api/v1/groupsread-only / full
参数
请求示例
curl --silent --show-error --fail-with-body -X GET \
"$NSD_BASE_URL/groups?limit=100" \
-H "Authorization: Bearer $NSD_TOKEN" \
-H 'Accept: application/json'
响应状态
200 响应
{
"items": [
{
"auto_members": "example",
"created_at": "2026-09-09T10:00:00Z",
"created_by": "example",
"description": "用于生产自动化",
"id": "01K4EXAMPLE0000000000000",
"kind": "static",
"member_count": 1,
"name": "示例资源",
"realm_id": "01K4EXAMPLE0000000000000",
"slug": "example"
}
],
"next_cursor": "example"
}
错误响应均使用 Problem Details;调用方应判断 HTTP 状态和稳定的 code,不要解析 detail 文案。
创建用户组
POST/api/v1/groupsfull
请求体
request.json
{
"description": "用于生产自动化",
"name": "示例资源"
}
请求示例
curl --silent --show-error --fail-with-body -X POST \
"$NSD_BASE_URL/groups" \
-H "Authorization: Bearer $NSD_TOKEN" \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
--data @request.json
响应状态
201 响应
{
"auto_members": "example",
"created_at": "2026-09-09T10:00:00Z",
"created_by": "example",
"description": "用于生产自动化",
"id": "01K4EXAMPLE0000000000000",
"kind": "static",
"member_count": 1,
"name": "示例资源",
"realm_id": "01K4EXAMPLE0000000000000",
"slug": "example"
}
错误响应均使用 Problem Details;调用方应判断 HTTP 状态和稳定的 code,不要解析 detail 文案。
读取用户组
GET/api/v1/groups/{id}read-only / full
参数
请求示例
curl --silent --show-error --fail-with-body -X GET \
"$NSD_BASE_URL/groups/${GROUP_ID}" \
-H "Authorization: Bearer $NSD_TOKEN" \
-H 'Accept: application/json'
响应状态
200 响应
{
"auto_members": "example",
"created_at": "2026-09-09T10:00:00Z",
"created_by": "example",
"description": "用于生产自动化",
"id": "01K4EXAMPLE0000000000000",
"kind": "static",
"member_count": 1,
"name": "示例资源",
"realm_id": "01K4EXAMPLE0000000000000",
"slug": "example"
}
错误响应均使用 Problem Details;调用方应判断 HTTP 状态和稳定的 code,不要解析 detail 文案。
修改用户组
PATCH/api/v1/groups/{id}full
参数
请求体
request.json
{
"description": "用于生产自动化",
"name": "示例资源"
}
请求示例
curl --silent --show-error --fail-with-body -X PATCH \
"$NSD_BASE_URL/groups/${GROUP_ID}" \
-H "Authorization: Bearer $NSD_TOKEN" \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
--data @request.json
响应状态
200 响应
{
"auto_members": "example",
"created_at": "2026-09-09T10:00:00Z",
"created_by": "example",
"description": "用于生产自动化",
"id": "01K4EXAMPLE0000000000000",
"kind": "static",
"member_count": 1,
"name": "示例资源",
"realm_id": "01K4EXAMPLE0000000000000",
"slug": "example"
}
错误响应均使用 Problem Details;调用方应判断 HTTP 状态和稳定的 code,不要解析 detail 文案。
删除用户组
DELETE/api/v1/groups/{id}full
参数
请求示例
curl --silent --show-error --fail-with-body -X DELETE \
"$NSD_BASE_URL/groups/${GROUP_ID}" \
-H "Authorization: Bearer $NSD_TOKEN" \
-H 'Accept: application/json'
响应状态
204 响应
成功,无响应体。
错误响应均使用 Problem Details;调用方应判断 HTTP 状态和稳定的 code,不要解析 detail 文案。
列出组成员
GET/api/v1/groups/{id}/membersread-only / full
参数
请求示例
curl --silent --show-error --fail-with-body -X GET \
"$NSD_BASE_URL/groups/${GROUP_ID}/members" \
-H "Authorization: Bearer $NSD_TOKEN" \
-H 'Accept: application/json'
响应状态
200 响应
[
{
"created_at": "2026-09-09T10:00:00Z",
"disabled": false,
"email": "operator@example.com",
"id": "01K4EXAMPLE0000000000000",
"last_login_at": "2026-09-09T10:00:00Z",
"mfa_enabled": false,
"name": "示例资源",
"realm_id": "01K4EXAMPLE0000000000000",
"role": "admin"
}
]
错误响应均使用 Problem Details;调用方应判断 HTTP 状态和稳定的 code,不要解析 detail 文案。
添加组成员
POST/api/v1/groups/{id}/membersfull
参数
请求体
request.json
{
"user_id": "01K4USER000000000000000000"
}
请求示例
curl --silent --show-error --fail-with-body -X POST \
"$NSD_BASE_URL/groups/${GROUP_ID}/members" \
-H "Authorization: Bearer $NSD_TOKEN" \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
--data @request.json
响应状态
200 响应
[
{
"created_at": "2026-09-09T10:00:00Z",
"disabled": false,
"email": "operator@example.com",
"id": "01K4EXAMPLE0000000000000",
"last_login_at": "2026-09-09T10:00:00Z",
"mfa_enabled": false,
"name": "示例资源",
"realm_id": "01K4EXAMPLE0000000000000",
"role": "admin"
}
]
错误响应均使用 Problem Details;调用方应判断 HTTP 状态和稳定的 code,不要解析 detail 文案。
移除组成员
DELETE/api/v1/groups/{id}/members/{user_id}full
参数
请求示例
curl --silent --show-error --fail-with-body -X DELETE \
"$NSD_BASE_URL/groups/${GROUP_ID}/members/${USER_ID}" \
-H "Authorization: Bearer $NSD_TOKEN" \
-H 'Accept: application/json'
响应状态
204 响应
成功,无响应体。
错误响应均使用 Problem Details;调用方应判断 HTTP 状态和稳定的 code,不要解析 detail 文案。
列出访问授权
GET/api/v1/policiesread-only / full
参数
请求示例
curl --silent --show-error --fail-with-body -X GET \
"$NSD_BASE_URL/policies?limit=100" \
-H "Authorization: Bearer $NSD_TOKEN" \
-H 'Accept: application/json'
响应状态
200 响应
{
"items": [
{
"action": "allow",
"compile_error": "example",
"compile_error_code": "example",
"compile_status": {},
"conditions": {},
"created_at": "2026-09-09T10:00:00Z",
"created_by": "example",
"enabled": true,
"enforced_at": "2026-09-09T10:00:00Z",
"id": "01K4EXAMPLE0000000000000",
"name": "示例资源",
"realm_id": "01K4EXAMPLE0000000000000",
"resource": {
"type": "service",
"service_id": "01K4SERVICE00000000000000"
},
"subject": {
"type": "user",
"user_id": "01K4USER000000000000000000"
},
"version": 1
}
],
"next_cursor": "example"
}
错误响应均使用 Problem Details;调用方应判断 HTTP 状态和稳定的 code,不要解析 detail 文案。
创建访问授权
POST/api/v1/policiesfull
请求体
request.json
{
"conditions": {},
"enabled": true,
"enforced_at": "2026-09-09T10:00:00Z",
"name": "示例资源",
"resource": {
"type": "service",
"service_id": "01K4SERVICE00000000000000"
},
"subject": {
"type": "user",
"user_id": "01K4USER000000000000000000"
}
}
请求示例
curl --silent --show-error --fail-with-body -X POST \
"$NSD_BASE_URL/policies" \
-H "Authorization: Bearer $NSD_TOKEN" \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
--data @request.json
响应状态
201 响应
{
"distribution": {
"failed": 1,
"gateways": 1,
"sites": 1
},
"policy": {
"action": "allow",
"compile_error": "example",
"compile_error_code": "example",
"compile_status": "compiled",
"conditions": {},
"created_at": "2026-09-09T10:00:00Z",
"created_by": "example",
"enabled": true,
"enforced_at": "2026-09-09T10:00:00Z",
"id": "01K4EXAMPLE0000000000000",
"name": "示例资源",
"realm_id": "01K4EXAMPLE0000000000000",
"resource": {
"type": "service",
"service_id": "01K4SERVICE00000000000000"
},
"subject": {
"type": "user",
"user_id": "01K4USER000000000000000000"
},
"version": 1
}
}
错误响应均使用 Problem Details;调用方应判断 HTTP 状态和稳定的 code,不要解析 detail 文案。
批量创建访问授权
POST/api/v1/policies/batchfull
请求体
request.json
{
"policies": [
{
"conditions": {},
"enabled": true,
"enforced_at": "2026-09-09T10:00:00Z",
"name": "示例资源",
"resource": {
"type": "service",
"service_id": "01K4SERVICE00000000000000"
},
"subject": {
"type": "user",
"user_id": "01K4USER000000000000000000"
}
}
]
}
请求示例
curl --silent --show-error --fail-with-body -X POST \
"$NSD_BASE_URL/policies/batch" \
-H "Authorization: Bearer $NSD_TOKEN" \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
--data @request.json
响应状态
201 响应
{
"distribution": {
"failed": 1,
"gateways": 1,
"sites": 1
},
"policies": [
{
"action": "allow",
"compile_error": "example",
"compile_error_code": "example",
"compile_status": {},
"conditions": {},
"created_at": "2026-09-09T10:00:00Z",
"created_by": "example",
"enabled": true,
"enforced_at": "2026-09-09T10:00:00Z",
"id": "01K4EXAMPLE0000000000000",
"name": "示例资源",
"realm_id": "01K4EXAMPLE0000000000000",
"resource": {
"type": "service",
"service_id": "01K4SERVICE00000000000000"
},
"subject": {
"type": "user",
"user_id": "01K4USER000000000000000000"
},
"version": 1
}
]
}
错误响应均使用 Problem Details;调用方应判断 HTTP 状态和稳定的 code,不要解析 detail 文案。
读取访问授权
GET/api/v1/policies/{id}read-only / full
参数
请求示例
curl --silent --show-error --fail-with-body -X GET \
"$NSD_BASE_URL/policies/${POLICY_ID}" \
-H "Authorization: Bearer $NSD_TOKEN" \
-H 'Accept: application/json'
响应状态
200 响应
{
"action": "allow",
"compile_error": "example",
"compile_error_code": "example",
"compile_status": "compiled",
"conditions": {},
"created_at": "2026-09-09T10:00:00Z",
"created_by": "example",
"enabled": true,
"enforced_at": "2026-09-09T10:00:00Z",
"id": "01K4EXAMPLE0000000000000",
"name": "示例资源",
"realm_id": "01K4EXAMPLE0000000000000",
"resource": {
"type": "service",
"service_id": "01K4SERVICE00000000000000"
},
"subject": {
"type": "user",
"user_id": "01K4USER000000000000000000"
},
"version": 1
}
错误响应均使用 Problem Details;调用方应判断 HTTP 状态和稳定的 code,不要解析 detail 文案。
修改访问授权
PATCH/api/v1/policies/{id}full
参数
请求体
request.json
{
"conditions": {},
"enabled": true,
"enforced_at": "2026-09-09T10:00:00Z",
"name": "示例资源",
"resource": {
"type": "service",
"service_id": "01K4SERVICE00000000000000"
},
"subject": {
"type": "user",
"user_id": "01K4USER000000000000000000"
}
}
请求示例
curl --silent --show-error --fail-with-body -X PATCH \
"$NSD_BASE_URL/policies/${POLICY_ID}" \
-H "Authorization: Bearer $NSD_TOKEN" \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
--data @request.json
响应状态
200 响应
{
"distribution": {
"failed": 1,
"gateways": 1,
"sites": 1
},
"policy": {
"action": "allow",
"compile_error": "example",
"compile_error_code": "example",
"compile_status": "compiled",
"conditions": {},
"created_at": "2026-09-09T10:00:00Z",
"created_by": "example",
"enabled": true,
"enforced_at": "2026-09-09T10:00:00Z",
"id": "01K4EXAMPLE0000000000000",
"name": "示例资源",
"realm_id": "01K4EXAMPLE0000000000000",
"resource": {
"type": "service",
"service_id": "01K4SERVICE00000000000000"
},
"subject": {
"type": "user",
"user_id": "01K4USER000000000000000000"
},
"version": 1
}
}
错误响应均使用 Problem Details;调用方应判断 HTTP 状态和稳定的 code,不要解析 detail 文案。
删除访问授权
DELETE/api/v1/policies/{id}full
参数
请求示例
curl --silent --show-error --fail-with-body -X DELETE \
"$NSD_BASE_URL/policies/${POLICY_ID}" \
-H "Authorization: Bearer $NSD_TOKEN" \
-H 'Accept: application/json'
响应状态
204 响应
成功,无响应体。
错误响应均使用 Problem Details;调用方应判断 HTTP 状态和稳定的 code,不要解析 detail 文案。
返回 API 参考总览。