![](/img/trans.png)
[英]KeyCloak 7.0.0 throws NullPointerException if select "NO_CACHE" cache policy for User Storage SPI
[英]keycloak SPI for client policy?
我正在嘗試為客戶端策略實現SPI
以替換我在js
的策略。
我實現PolicyProvider
相似, 這和PolicyProviderFactory
像這樣,那我我復制jar
到standalone/deployments
在解釋實現SPI
我可以在日志中看到 jar 已經部署:
08:17:02,647 INFO [stdout] (MSC service thread 1-3) about to start org.keycloak.services.util.JsonConfigProvider$JsonScope@266abf6d
08:17:02,682 WARN [org.keycloak.services] (MSC service thread 1-3) KC-SERVICES0047: myEvListener (example.myProvider.EvListenerProviderFactory) is implementing the internal SPI eventsListener. This SPI is internal and may change without notice
08:17:02,692 WARN [org.keycloak.services] (MSC service thread 1-3) KC-SERVICES0047: myRolePolicy (example.myProvider.MyPolicyProviderFactory) is implementing the internal SPI policy. This SPI is internal and may change without notice
08:17:02,814 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) WFLYSRV0010: Deployed "myPolicyProvider.jar" (runtime-name : "myPolicyProvider.jar")
現在我找不到使用我的SPI
創建客戶端策略的方法
在服務器信息中,我可以看到我的策略( my-role-policy
和my-js-policy
)在策略提供者中列出:
如果有人能指出我正確的方向,我將不勝感激。
為了創建一個策略,需要發出一個 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 請求示例:
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"}'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.