Closed csbrogi closed 4 years ago
A PATCH Request on a Group does not remove the member Sample
**PATCH** request Url: https://keycloa/auth/realms/Demo/scim/v2/Groups/e0d1016a-26dc-446f-8dab-2fd29aa4f779 Parameters : { "schemas":["urn:ietf:params:scim:api:messages:2.0:PatchOp"], "Operations":[ {"op":"Remove","path":"members[value eq \"fb945029-265c-4c41-9ada-459f013ed126\"]"} ] }
A Fix could be:
private GroupModel groupToModel(KeycloakSession keycloakSession, Group group, GroupModel groupModel) { RealmModel realmModel = keycloakSession.getContext().getRealm(); group.getDisplayName().ifPresent(groupModel::setName); if (group.getExternalId().isPresent()) { groupModel.setSingleAttribute(AttributeNames.RFC7643.EXTERNAL_ID, group.getExternalId().get()); } List<Member> groupMembers = group.getMembers(); keycloakSession.users().getGroupMembers(realmModel, groupModel).stream().forEach(modelMember -> { boolean found = false; for ( Member groupMember : groupMembers ) { if (groupMember.getType().isPresent() && groupMember.getType().get().equalsIgnoreCase("User")) { if (groupMember.getValue().get().equals(modelMember.getId())) { found = false; } } } if (!found) { modelMember.leaveGroup(groupModel); } });
fixed
A PATCH Request on a Group does not remove the member Sample
A Fix could be: