You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
'Aggregate attribute values' mapper option not applied to group hierarchy #11255
In a group hierarchy Multivalued attributes (with 'Aggregate attribute values' option set) are not properly aggregated into the Generated Access Token.
Version
12.0.4
Expected behavior
For a 'User Attribute' token claim that is Multivalued and has the 'Aggregate attribute values' option set, values found for a user's group should be combined with attribute values found for any ancestor of that group.
Actual behavior
A parent group's attribute values are ignored instead of aggregated (even though inheritance works fine when the child group contains no values for the attribute).
How to Reproduce?
Create a group, named A with attribute 'x' with value A##1
Create a group B, that is a child group of A, with attribute 'x' with value B##2
Create a user C that is a member of group B.
Make a User Attribute mapper for a User Attribute 'x' and Token Claim Name 'x' with the 'Multivalued' and 'Aggregate attribute values' options set.
Include the mapper in a Client Scope that is included to a client's "Assigned Default Client Scopes" and evaluate for user C.
The evaluation result ('Generated Access Token') includes claim 'x' with values ["B", "2"] (instead of the desired ["A", "1", "B", "2"]).
Anything else?
This is KEYCLOAK-17252 re-entered.
It was closed as if outdated, but for us it still is and has always been a very relevant current issue (running with the provided PR in production).
The PR that fixes this issue: #7871
(after all this time only the added unit test causes a git conflict right now; we will address this).
@lhanusov Thanks for looking into this! And I'm sorry to hear that you can't reproduce the evaluation.
I just learned that the UI w.r.t. mappers has changed in some version after 12 (IIRC Mappers used to be a main item in the side bar), so that probably explains why step 4. and 5. don't work exactly in that order any more. Mappers are now (I am looking at our Keycloak 18 install) managed from within a specific Client Scope and I can see why that would make sense.
The new reproduction scenario would now read:
Create a group, named A with attribute 'x' with value A##1
Create a group B, that is a child group of A, with attribute 'x' with value B##2
Create a user C that is a member of group B.
Make a Client Scope 'x' and on its Mappers tab create a new Mapper 'x' with Mapper Type 'User Attribute', User Attribute 'x', Token Claim Name 'x' with the 'Multivalued' and 'Aggregate attribute values' options set.
Evaluate the Client Scope 'x', including Mapper 'x' for user C.
Actually, this requires some not-so-intuitive UI steps:
a. Include Client Scope 'x' in the "Assigned Default Client Scopes" (via 'Default Client Scopes' tab on the 'Client Scopes' screen or... via the 'Client Scopes' tab on the 'Clients' screen for a specific client).
b. Find the 'evaluate' sub-tab within the 'Client Scopes' tab on the 'Clients' screen for a specific client, select user C and press the 'Evaluate' button.
The evaluation result ('Generated Access Token') includes claim 'x' with values ["B", "2"] (instead of the desired ["A", "1", "B", "2"]).
@jurjanpaul Thank you for your help, I had actually done same steps before, but it didn't work. Thanks to your steps, I've realized the problem is somewhere else. It's a bug in the new UI, because it can't resolve user names with single character. When the user name has more characters (e.g 5), the evaluate button works and shows the requested values.
Activity
lhanusov commentedon Sep 7, 2022
@jurjanpaul Hi, can you please rephrase the steps 4. and 5.? I am not able to reproduce your evaluation. Thanks
jurjanpaul commentedon Sep 7, 2022
@lhanusov Thanks for looking into this! And I'm sorry to hear that you can't reproduce the evaluation.
I just learned that the UI w.r.t. mappers has changed in some version after 12 (IIRC Mappers used to be a main item in the side bar), so that probably explains why step 4. and 5. don't work exactly in that order any more. Mappers are now (I am looking at our Keycloak 18 install) managed from within a specific Client Scope and I can see why that would make sense.
The new reproduction scenario would now read:
A##1B##2Actually, this requires some not-so-intuitive UI steps:
a. Include Client Scope 'x' in the "Assigned Default Client Scopes" (via 'Default Client Scopes' tab on the 'Client Scopes' screen or... via the 'Client Scopes' tab on the 'Clients' screen for a specific client).
b. Find the 'evaluate' sub-tab within the 'Client Scopes' tab on the 'Clients' screen for a specific client, select user C and press the 'Evaluate' button.
The evaluation result ('Generated Access Token') includes claim 'x' with values
["B", "2"](instead of the desired["A", "1", "B", "2"]).I hope this helps.
lhanusov commentedon Sep 8, 2022
@jurjanpaul Thank you for your help, I had actually done same steps before, but it didn't work. Thanks to your steps, I've realized the problem is somewhere else. It's a bug in the new UI, because it can't resolve user names with single character. When the user name has more characters (e.g 5), the evaluate button works and shows the requested values.
jurjanpaul commentedon Sep 8, 2022
@lhanusov Aha! Oops. :-) So, instead of a user C we need a user "Coworker" or something.
Mapper option 'Aggregate attribute values' is now applied to group hi…