使用 cUrl 通过其 REST API 配置 Keycloak

Configuring Keycloak through its REST API with cUrl

我需要像 this blog post 一样配置 Keycloak 以获取 JWT 令牌,但我必须使用 cUrl 来完成。他们创建了一个客户端,然后更新它,将 access type 设置为 confidential,将 Direct Grant Flow 设置为 direct grant,并将 Browser Flow 设置为 browser。来自网络 UI 的 PUT 请求执行此操作有一些 uuids 他们似乎无处不在。这是有效载荷的相关部分:

"authenticationFlowBindingOverrides":{"browser":"6d77c4c7-15cf-4474-9b9f-7439dbc83b83","direct_grant":"5cb10cdb-9902-4f7f-b9da-68f887c49a75"}

地图 ClientRepresentation are no help. They show all fields are optional, which doesn't make sense, and the authenticationFlowBindingOverrides is a Map, but the link in their docs 的文档已失效。

有谁知道他们从哪里获得浏览器和 direct_grant 的 uuid?

PUT 负载中也没有任何内容将 Access Type 设置为 confidential

如果有人有 blog post 中 UI 步骤的 cUrl 实现,将不胜感激。

The PUT request from the web UI that does this has some uuids that they seem to pull out of nowhere.

这些 uuid 是由 keycloak 生成的,您需要调用端点来获取它们:

GET KEYCLOAK_HOST/auth/admin/realms/<YOUR_REALM>/authentication/flows

JSON 响应中,您需要对其进行解析并获取 alias: "browser" 和别名的字段 id"direct grant".

之后调用端点:

PUT KEYCLOAK_HOST/auth/admin/realms/<YOUR_REALM>/clients/<YOUR_CLIENT_ID>

具有以下负载:

'{"publicClient":false,"clientAuthenticatorType":"client-secret","authenticationFlowBindingOverrides":{"direct_grant":"<DIRECT_GRANT_ID>","browser":"<BROWSER_ID>"}}'

There is also nothing in the PUT payload that sets the Access Type to confidential.

您需要将字段 publicClient 设置为 false