本文介绍了具有多个值的Keycloak用户属性(列表)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Keycloak用例,其中单个用户可能有多个客户编号.这些客户编号将需要发送到服务提供商/客户,并且管理员也可以轻松地对其进行更新.一些用户可能有数百个客户编号.目前,我正在使用名为"customerNumbers"的单个用户属性,其中客户号用逗号分隔,但是我想要:

I'm having a Keycloak use case where single user may have multiple customer numbers. These customer numbers would need to be sent to service provider / client and also be easily updated by administrators. Some users may have hundreds of customer numbers. Currently I'm using single user attribute named "customerNumbers" where the customer numbers are separated by comma but I'd like:

  1. 使管理员可以在其自己的字段中查看每个客户编号
  2. 将客户编号作为JSON数组而不是逗号分隔的声明发送

所以代替这个:

我想要这样的东西:

而不是

"customers": {
"customerNumbers": "140661,140662"
},

我想要这样的东西:

"customers": [
    {"customerNumber": "140661"},
    {"customerNumber": "140662"}
],

一个人应该如何处理这种情况?

How should one approach this kind of situation?

推荐答案

您需要在用户属性中添加值,例如[{"customerNumber": "140661"}, {"customerNumber": "140662"}]

You need to add your values in the user attributes like this [{"customerNumber": "140661"}, {"customerNumber": "140662"}]

[Keycloak user management, attributes tab][1]

您的客户端映射器将需要这样(我想我尝试过其他所有选项)

your client mapper will need be like this (i think i tried every other option)

在此处输入图片描述

这篇关于具有多个值的Keycloak用户属性(列表)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 22:31