8.4.2. 管理资源
资源服务器可以使用 UMA 兼容端点远程管理其资源。
http://${host}:${port}/realms/${realm-name}/authz/protection/resource_set
此端点提供概述的操作(明确省略的路径):
- 创建资源设置描述:POST /resource_set
- 读取资源集描述:GET /resource_set/{_id}
- 更新资源设置描述:PUT /resource_set/{_id}
- 删除资源设置描述:DELETE /resource_set/{_id}
- 列出资源设置描述:GET /resource_set
有关这些操作的合同的更多信息,请参阅 UMA 资源注册 API。
8.4.2.1. 创建资源 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
要创建资源,您必须发送 HTTP POST 请求,如下所示:
curl -v -X POST \
http://${host}:${port}/realms/${realm-name}/authz/protection/resource_set \
-H 'Authorization: Bearer '$pat \
-H 'Content-Type: application/json' \
-d '{
"name":"Tweedl Social Service",
"type":"http://www.example.com/rsrcs/socialstream/140-compatible",
"icon_uri":"http://www.example.com/icons/sharesocial.png",
"resource_scopes":[
"read-public",
"post-updates",
"read-private",
"http://www.example.com/scopes/all"
]
}'
默认情况下,资源的所有者是资源服务器。如果要定义不同的所有者,如特定用户,您可以发送如下请求:
curl -v -X POST \
http://${host}:${port}/realms/${realm-name}/authz/protection/resource_set \
-H 'Authorization: Bearer '$pat \
-H 'Content-Type: application/json' \
-d '{
"name":"Alice Resource",
"owner": "alice"
}'
其中可使用用户名或用户的标识符来设置属性 所有者。