如何通过 Keycloak 的 REST API 使用以下值(如附图所示)创建协议(protocol)映射器?我在文档中找不到它 - 我确实找到了这个:Protocol Mapper - 但是 ProtocolMapperRepresentation接受一个 map 和几个字符串。当我看到 UI 时 - 我看到了更多的字段,但我不确定我是否正在查看正确的 API。
这是用户界面:
如何通过 API 实现?
最佳答案
How do I create Protocol Mappers with the following values (as seen in the attached image) via Keycloak's REST API?
您可以通过调用以下端点来完成此操作:
POST ${KEYCLOAK_HOST}/auth/admin/realms/${REALM_NAME}/clients/${ID of the Client}/protocol-mappers/models
具有以下数据:
{"protocol":"openid-connect","config":{"id.token.claim":"true","access.token.claim":"true","userinfo.token.claim":"true","multivalued":"","aggregate.attrs":"","user.attribute":"some-attribute","claim.name":"some-attribute","jsonType.label":"String"},"name":"some-attribute","protocolMapper":"oidc-usermodel-attribute-mapper"}
I did find this: Protocol Mapper - but the ProtocolMapperRepresentation takes in a Map and a couple of Strings. When I see the UI - I see a lot more fields and I'm not sure if I'm looking at the right API.
这是设计使然;使端点足够抽象以接受不同类型的协议(protocol)映射器。该 Map 基本上对配置部分进行编码,这些配置部分往往会从映射器更改为映射器。
关于keycloak - 如何通过 REST API 为 Keycloak 中的每个用户属性创建映射器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66912222/