Skip to content

'Aggregate attribute values' mapper option not applied to group hierarchy #11255

Closed

Description

@jurjanpaul

Describe the bug

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?

  1. Create a group, named A with attribute 'x' with value A##1
  2. Create a group B, that is a child group of A, with attribute 'x' with value B##2
  3. Create a user C that is a member of group B.
  4. Make a User Attribute mapper for a User Attribute 'x' and Token Claim Name 'x' with the 'Multivalued' and 'Aggregate attribute values' options set.
  5. 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).

Activity

  1. added
    kind/bug
    on Apr 12, 2022
  2. added
    area/core
    on Apr 21, 2022
  3. lhanusov commented on Sep 7, 2022

    @lhanusov
    Contributor

    @jurjanpaul Hi, can you please rephrase the steps 4. and 5.? I am not able to reproduce your evaluation. Thanks

  4. jurjanpaul commented on Sep 7, 2022

    @jurjanpaul
    ContributorAuthor

    @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:

    1. Create a group, named A with attribute 'x' with value A##1
    2. Create a group B, that is a child group of A, with attribute 'x' with value B##2
    3. Create a user C that is a member of group B.
    4. 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.
    5. 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"]).

    I hope this helps.

  5. lhanusov commented on Sep 8, 2022

    @lhanusov
    Contributor

    @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.

  6. jurjanpaul commented on Sep 8, 2022

    @jurjanpaul
    ContributorAuthor

    @lhanusov Aha! Oops. :-) So, instead of a user C we need a user "Coworker" or something.

  7. added a commit that references this issue on Sep 12, 2022
    eb0124e
  8. added this to the 20.0.0 milestone on Sep 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/corehelp wantedkind/bug

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions