Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group Attribute Search Erroneously returns when searching for nested group #16535

Closed
2 tasks done
alice-wondered opened this issue Jan 19, 2023 · 2 comments · Fixed by #16540
Closed
2 tasks done

Group Attribute Search Erroneously returns when searching for nested group #16535

alice-wondered opened this issue Jan 19, 2023 · 2 comments · Fixed by #16540
Assignees
Labels
area/storage Indicates an issue that touches storage (change in data layout or data manipulation) kind/enhancement Categorizes a PR related to an enhancement team/rh-iam
Milestone

Comments

@alice-wondered
Copy link
Contributor

Before reporting an issue

  • I have searched existing issues
  • I have reproduced the issue with the latest release

Area

storage

Describe the bug

When given a group structure such as

  • group1 (attr: <test, test> )
  • group2
    -- group2_a (attr: <group2_test, group2_test>)
    -- group2_b

Querying for the attribute (test, test) of group1 will correctly return group1

Querying for the attribute (group2_test, group2_test) will incorrectly return group2 as well as both sub groups.

Version

confirmed on main branch

Expected behavior

Querying for a sub group should only return that sub group

However, a test was added that checks that the problematic behavior actually does occur. I believe this was added erroneously (by me) and not caught.

`GroupSearchTest:

Actual behavior

Querying for a sub group by attribute should only return that sub group as it's the only one relevant to the search

How to Reproduce?

GET /auth/admin/realms/redhat-external/groups?q=:&first=0&max=20

Anything else?

No response

@alice-wondered alice-wondered added kind/bug Categorizes a PR related to a bug status/triage labels Jan 19, 2023
@ghost ghost added the area/storage Indicates an issue that touches storage (change in data layout or data manipulation) label Jan 19, 2023
alice-wondered added a commit to alice-wondered/keycloak that referenced this issue Jan 19, 2023
@hmlnarik hmlnarik added kind/enhancement Categorizes a PR related to an enhancement and removed kind/bug Categorizes a PR related to a bug labels Jan 20, 2023
@hmlnarik
Copy link
Contributor

This behaviour is expected since this is the way the REST endpoints were crafted for use in admin console.

That said, the behaviour you are asking for, i.e. returning the list of the groups directly, is reasonable.

I suggest extending the org.keycloak.services.resources.admin.GroupsResource.getGroups method with ignoreHierarchy boolean flag. If false (default), the behaviour remains as is today. If true, it would return only those groups matching the query without resolving their hierarchy, leading to extending / updating the searchGroups* methods in the ModelToRepresentation class.

@alice-wondered
Copy link
Contributor Author

I have updated my PR to extend the behavior as suggested and added another test case that shows that this functionality is working as expected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/storage Indicates an issue that touches storage (change in data layout or data manipulation) kind/enhancement Categorizes a PR related to an enhancement team/rh-iam
Projects
None yet
2 participants