-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Fixes #9482: A user could be assigned to a parent group if he is already assigned to a subgroup. #10785
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
Fixes #9482: A user could be assigned to a parent group if he is already assigned to a subgroup. #10785
Conversation
4839c94
to
22db324
Compare
Thanks for contributing to this project with this pull request! Please add This will help collaboration on GitHub in two ways:
Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the test.
Sadly, the fix is not valid. The isMemberOf
accounts for recursive walk of group hierarchy. This is not the case with the code proposed in this PR which only checks the direct assignment of a user to groups.
@hmlnarik In the light of #12726 (reply in thread), do you think this could be merged? Also tests need to be rerun I guess... |
22db324
to
8c5ce2c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR. Could you please rebase, it has conflicts, and also please see inline
model/jpa/src/main/java/org/keycloak/models/jpa/UserAdapter.java
Outdated
Show resolved
Hide resolved
...e/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/UserTest.java
Outdated
Show resolved
Hide resolved
8c5ce2c
to
b89a6c6
Compare
...e/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/UserTest.java
Outdated
Show resolved
Hide resolved
model/jpa/src/main/java/org/keycloak/models/jpa/UserAdapter.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the changes, looks better now. Could you please see the comments inline?
Nit: For the sake of better readability, leveraging the newly introduced method RoleUtils.isDirectMember
in the changed lines which currently use getGroupsStream().{none,any}Match
would be preferred.
services/src/main/java/org/keycloak/services/resources/admin/UserResource.java
Outdated
Show resolved
Hide resolved
… is already assigned to a subgroup.
b89a6c6
to
5ccc549
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR!
Closes #9482
Changed precondition for joining a group from is not a member to has group not directly assigned.