8.4.2. 管理资源
资源服务器可以使用兼容 UMA 的端点远程管理其资源。
http://${host}:${port}/auth/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}/auth/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}/auth/realms/${realm_name}/authz/protection/resource_set \ -H 'Authorization: Bearer '$pat \ -H 'Content-Type: application/json' \ -d '{ "name":"Alice Resource", "owner": "alice" }'
可以使用用户名或用户标识符来设置属性 所有者
。