Repository navigation
Conversation
Prasad484
force-pushed
the
scim-entra-remove-by-value
branch
from
November 18, 2026 13:26
452b68f to
20223cb
Compare
Prasad484
marked this pull request as ready for review
November 18, 2026 13:27
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Malformed members or groups removal arrays containing null or string entries can trigger unhandled exceptions and HTTP 500 responses instead of validation errors returning 400.
1 open issue
What changed in this PR
This PR fixes SCIM PATCH removals that previously returned success without changing membership. It supports Microsoft Entra ID’s value-list format for group members and extends the same behavior to user groups, addressing #55307 while leaving unfiltered replacement behavior in #52752 unchanged.
Changes:
- Pass PATCH removal values through the shared schema layer to select memberships to remove.
- Reject conflicting filters and values, and group member entries with missing IDs.
- Add membership and service-account regression tests, usage examples, and upgrade guidance.
| File | Description |
|---|---|
| scim/tests/base/src/test/java/org/keycloak/tests/scim/tck/UserTest.java | Tests user-group removal by value and invalid requests. |
| scim/tests/base/src/test/java/org/keycloak/tests/scim/tck/GroupTest.java | Tests member removal, events, and invalid targets. |
| scim/tests/base/src/test/java/org/keycloak/tests/scim/tck/AdminGroupProtectionTest.java | Tests service-account protection during value-based removal. |
| scim/model/src/main/java/org/keycloak/scim/model/group/GroupCoreModelSchema.java | Rejects missing member IDs during add and remove. |
| scim/core/src/main/java/org/keycloak/scim/resource/spi/AbstractScimResourceTypeProvider.java | Forwards operation values to schema removal. |
| scim/core/src/main/java/org/keycloak/scim/resource/schema/path/Path.java | Exposes whether a path contains a filter. |
| scim/core/src/main/java/org/keycloak/scim/resource/schema/ModelSchema.java | Adds a value-aware removal overload. |
| scim/core/src/main/java/org/keycloak/scim/resource/schema/AbstractModelSchema.java | Resolves removal targets and rejects filter/value conflicts. |
| scim/core/src/main/java/org/keycloak/scim/protocol/request/PatchRequest.java | Adds a builder overload for removal values. |
| docs/documentation/upgrading/topics/changes/changes-27_0_0.adoc | Explains changed behavior and membership reconciliation guidance. |
| docs/documentation/server_admin/topics/scim/managing-users.adoc | Documents removing user groups by value. |
| docs/documentation/server_admin/topics/scim/managing-groups.adoc | Documents member removal by value and error behavior. |
Review effort: Balanced
… value A PATCH remove with a list in the operation's value and no filter in the path now removes the listed entries, instead of answering 200 and changing nothing. On a group, path members removes those members; on a user, path groups removes the user from those groups. The value is passed to the model schema; a remove with both a filter and a value, and a group member entry without a value, are rejected with 400. An add or remove entry that is not an object, such as null or a bare id, is rejected with 400 instead of failing with 500. Closes keycloak#55307 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Prasad Rahatekar <83812676+Prasad484@users.noreply.github.com>
Prasad484
force-pushed
the
scim-entra-remove-by-value
branch
from
November 19, 2026 01:44
20223cb to
d3fc17e
Compare
Comment on lines
+125
to
+127
| if (hasValue && attribute.isMultivalued() && attribute.getComplexType() != null) { | ||
| // the value lists the values to remove, e.g. "members" with [{"value": "<user id>"}], normalized as for add | ||
| values = ofNullable(resolveAttributes(path.getPath(), value).get(attribute)).orElse(NullNode.getInstance()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #55307
Why honour
valueinstead of rejecting itRFC 7644 §3.5.2.2 defines no
valueforremove, and, read strictly, aremoveonmemberswithout a filter removes every member. Microsoft Entra ID still sends exactly this request to remove one member (Microsoft's SCIM tutorial, "Update Group [Remove Members]"). Clearing the group would be destructive, and a 400 would leave Entra-managed groups unable to lose members at all, so the listed members are removed. That is what Entra expects, and it gives the same result as the filter formmembers[value eq "<id>"].Decisions
AbstractModelSchema.remove, which users and groups share, so a userPATCHwith"path": "groups"and a value now removes the user from the listed groups. Before this change it also answered 200 and left the user in every group.emailsbehaves as before, because its remover always clears the email. The admin-v2 client schema implementsModelSchemadirectly and keeps the default overload, which ignores the value.removewith both a filter in the path and avalueis rejected with 400 for any user or group attribute, because the RFC does not define that combination and neither choice of which one wins is obviously right. Before, the value was ignored.valueis rejected with 400 on a groupaddas well asremove, instead of looking up a user with a missing id.[null]or["<id>"], is rejected with 400 onaddandremoveof any multi-valued complex attribute. On main,addalready fails with 500 for these entries, andremovewould have inherited that once it reads the value. The check sits inAbstractModelSchema.setValue, which both operations pass through, so they reject the same input the same way. PUT and create are left alone, since their values come from the typed representation.Not changed
A
removeonmemberswith neither a filter nor avaluestill removes nobody. That case is discussed on #52752 and is left out of this change.Review focus
AbstractModelSchema.remove, where the operation value is turned into the entries to remove, the entry check inAbstractModelSchema.setValue, and the two member loops inGroupCoreModelSchema, which now reject an entry without avalue.Local validation (main f2326fc)
./mvnw -pl scim/tests/base test -Dtest='GroupTest,AdminGroupProtectionTest'fails 4 of the 5 new group tests.testCannotRemoveServiceAccountByValuepasses on main too, since main also refuses that request; it guards that service accounts stay protected when they are named invalue.UserTest#testPatchRemoveGroupsByValuealso fails on main: after a 200, the user is still in all three groups. On main, anaddwith[null]or["<id>"]onmembersorgroupsanswers 500.quarkus/dist, which the test server is unpacked from):./mvnw -pl scim/core,scim/tests/base testpasses, with 51 unit tests and 308 integration tests (2 skipped, both already@Disabled), includingUserTest108,GroupTest42/42 andAdminGroupProtectionTest25/25../mvnw -Pspotless spotless:check -pl scim/core,scim/model,scim/tests/basepasses.Upgrade note
Added under Notable changes, because a client that received 200 for this request will now see members or groups removed, or a 400 for an unknown id, a filter with a value, or an entry that is not an object.
AI assistance: this change was prepared with Claude Code, an AI coding agent. I have reviewed it and will handle the review.