Keycloak user attributes with multiple values (list)

情到浓时终转凉″ 提交于 2021-01-28 19:51:14

问题


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. To offer the administrators possibility to see each customer number in its own field
  2. To send the customer numbers as an JSON array instead of comma separated claim

So instead of this:

I'd like something like this:

And instead of this

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

I'd like something like this:

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

How should one approach this kind of situation?


回答1:


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

ie [Keycloak user management, attributes tab][1]

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

enter image description here



来源:https://stackoverflow.com/questions/61132928/keycloak-user-attributes-with-multiple-values-list

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!