Situation
I have a keycloak server (v12.0.2) running with a client that has some roles. I can add custom attributes to that roles and retrieve them. No problem. But the roles always return an array.
entering key "foo" and value "bar" gives me
"attributes": {
"foo": [
"bar"
]
}
What I would like to have
I would like to have multiple entries in the array. To stay in the previous example, I would like to have "bar" and "baz".
"attributes": {
"foo": [
"bar",
"baz"
]
}
What I have tried
"attributes": {
"foo": [
"baz"
]
}
"attributes": {
"foo[0]": [
"bar"
],
"foo[1]": [
"baz"
]
}
"attributes": {
"foo": [
"bar,baz"
]
}
(and the same with ";" or " " respectively)
Is there any way to do that or do I have to go with custom defined separators and split the string in my application (which is not a problem, but I think getting the values as an array would be better)
You can use ##
as a delimiter, example: bar##baz
. But with this delimiter the order of the array is not guaranteed , though you save the data as bar##baz
the array may return as foo[0]= "baz"
and foo[1] as="bar"
.
If the order is not important you can try this delimiter.