1 回答
TA贡献1839条经验 获得超15个赞
为了创建策略,需要向以下位置发出 POST 请求:
http://${host}:${port}/auth/realms/${realm}/clients/${clientId}/authz/resource-server/policy/${policyId}
在哪里policyId指定PolicyProviderFactory
public String getId() {
return "myId";
}
您的帖子正文应该是 json
{
"decisionStrategy": "AFFIRMATIVE",
"logic": "POSITIVE",
"name": "policyName",
.... // other fields required in your policy implementation
}
卷曲请求示例:
curl --request POST \
--url http://${host}:${port}/auth/admin/realms/${realm}/clients/${clientId}/authz/resource-server/policy/${policyId} \
--header 'authorization: Bearer ${token}' \
--header 'content-type: application/json' \
--data '{"decisionStrategy": "AFFIRMATIVE","logic": "POSITIVE","name": "is-admin","role": "admin"}'
添加回答
举报