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

Removing all group attributes no longer works with keycloak-admin-client (java) #25677

Closed
1 task done
danielFesenmeyer opened this issue Dec 18, 2023 · 5 comments · Fixed by #25693
Closed
1 task done
Labels
area/admin/client-java kind/bug Categorizes a PR related to a bug priority/important Must be worked on very soon release/23.0.5 release/24.0.0
Milestone

Comments

@danielFesenmeyer
Copy link
Contributor

Before reporting an issue

  • I have read and understood the above terms for submitting issues, and I understand that my issue may be closed without action if I do not follow them.

Area

admin/client/java

Describe the bug

With Keycloak 22.x and previous versions, it was possible to remove all group attributes like this:

var group = groupResource.toRepresentation();
group.setAttributes(Collections.emptyMap());
groupResource.update(group);

This does no longer work with Keycloak 23.0.3. The group attributes remain unchanged.

Version

23.0.3

Expected behavior

All group attributes should be removed.

Actual behavior

The group attribues remain unchanged.

How to Reproduce?

See example code in the description.

Anything else?

Seems this has been introduced by this commit: #22700.
Because there is now this annotation on GroupRepresentation
@JsonInclude(JsonInclude.Include.NON_EMPTY)

This annotation causes the empty attributes not to be included in the request, and being ignored on the server, because the server removes attributes only when they are empty, not null.

@danielFesenmeyer danielFesenmeyer added kind/bug Categorizes a PR related to a bug status/triage labels Dec 18, 2023
@ghost ghost added the team/core label Dec 19, 2023
@mposolda mposolda added area/storage Indicates an issue that touches storage (change in data layout or data manipulation) and removed team/core labels Dec 19, 2023
@ghost ghost added the team/store label Dec 19, 2023
@mposolda mposolda added priority/blocker Highest Priority. Has a deadline and it blocks other tasks team/core labels Dec 19, 2023
@mposolda
Copy link
Contributor

Adding both areas admin/api and storage as it is possible that this is related to both storage and admin REST API.

And marking as critical for now until we investigate what is going on.

@mposolda mposolda added priority/important Must be worked on very soon area/admin/client-java status/regression and removed priority/blocker Highest Priority. Has a deadline and it blocks other tasks area/storage Indicates an issue that touches storage (change in data layout or data manipulation) area/admin/api team/store labels Dec 19, 2023
@mposolda mposolda added this to the 24.0.0 milestone Dec 19, 2023
@mposolda
Copy link
Contributor

I am unmarking as critical and marking as important . We may try to fix in Keycloak 24 if we have time, but probably not strictly a blocker. Not 100% sure, but it seems the issue is not on the server-side, but just in the java admin client.

When testing with the admin console with the scenario like this:

  • Go to some group in the admin console UI
  • Add attribute foo to the group and update group
  • Remove attribute foo (so the group does not have any attributes) and update group
  • Now the admin console send the HTTP PUT request with the group JSON with the attributes like "attributes": {} . On the server-side (in GroupResource.updateGroup() ), the group has attributes set as empty map, which causes attributes field to update correctly and existing attributes are removed from the group.

On the other hand, when testing with admin client, then the group in the GroupResource.updateGroup() has attributes set as null, which means existing attributes are not removed.

@danielFesenmeyer If you have a chance to send PR for this, it would be welcome.

@danielFesenmeyer
Copy link
Contributor Author

@mposolda OK, I've just started working on it.

danielFesenmeyer added a commit to bosch-io/keycloak that referenced this issue Dec 19, 2023
…ak-admin-client (java)

Closes keycloak#25677

Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch.com>
mposolda pushed a commit that referenced this issue Dec 20, 2023
…ak-admin-client (java)

Closes #25677

Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch.com>
@mposolda
Copy link
Contributor

@danielFesenmeyer Feel free to send PR also to release/23.0 if you want to have this in Keycloak 23.0.4 release. Please see https://github.com/keycloak/keycloak/blob/main/.github/scripts/pr-backport.sh for easily allow to create backporting PRs.

danielFesenmeyer added a commit to bosch-io/keycloak that referenced this issue Jan 9, 2024
…ak-admin-client (java)

Closes keycloak#25677

Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch.com>
(cherry picked from commit baafb67)
@danielFesenmeyer
Copy link
Contributor Author

danielFesenmeyer commented Jan 9, 2024

@mposolda Created a PR for release/23.0: #26030

ahus1 pushed a commit that referenced this issue Jan 9, 2024
…ak-admin-client (java)

Closes #25677

Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch.com>
(cherry picked from commit baafb67)
ShefeeqPM pushed a commit to ShefeeqPM/keycloak that referenced this issue Jan 27, 2024
…ak-admin-client (java)

Closes keycloak#25677

Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch.com>
Signed-off-by: ShefeeqPM <86718986+ShefeeqPM@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/admin/client-java kind/bug Categorizes a PR related to a bug priority/important Must be worked on very soon release/23.0.5 release/24.0.0
Projects
None yet
2 participants