1 回答

TA貢獻1839條經(jīng)驗 獲得超15個贊
為了創(chuàng)建策略,需要向以下位置發(fā)出 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"}'
添加回答
舉報