SCIM: let the client that creates a group own its members, so a group can accept a full member list on PUT · keycloak keycloak · Discussion #55340 · GitHub
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SCIM: let the client that creates a group own its members, so a group can accept a full member list on PUT
#55340
Today a SCIM PUT /Groups/{id} that carries members is refused, by design (#46216), and #53130 plans to accept members on POST while keeping PUT restricted. I'd like to propose a way to accept PUT safely, and ask whether it fits.
The problem
Okta applications built with the App Integration Wizard push groups only with PUT, sending the full member list each time, and the integration cannot be switched to PATCH. As captured on #53130 (by me with a wizard app, and by @wparr-circle with the Okta Provisioning Agent), only an empty group can reach Keycloak today. Every later add gets a 400 and Okta puts the group in an error state, and removing the last member gets a 200 that changes nothing (#54530).
Accepting PUT with plain replace semantics would fix Okta and cause a new problem. A replace removes everyone the caller did not list. That includes members an administrator added in Keycloak, and members another SCIM client added to the same group. I assume this is part of why PUT was restricted.
The proposal
The SCIM client that creates a group owns it, and only that client changes the group's members. The client is the one the access token was issued to. The membership is what the owner last sent.
For example, Okta creates Finance with Alice and Bob, so Okta owns Finance. Okta then sends a PUT listing only Alice, and Bob leaves the group. Another SCIM client that tries to add to, remove from, replace or delete Finance gets a 403.
This matches how Okta describes group push itself: once a group is pushed, Okta becomes the group source.
The rules:
POST /Groups with members creates the group with those members, and the calling client becomes its owner.
The owner can PUT a full member list (members not listed leave), PATCHadd, remove and replace, including Entra's remove with a value list (Remove the SCIM group members or user groups listed in a PATCH remove value #55310), and DELETE. Any other SCIM client gets a 403 for all of them, including a delete of a group that has an owned group below it.
A user's groups on /Users cannot add or remove a membership of an owned group (400, mutability), as RFC 7643 section 4.1.2 describes, so an owned group has one write path.
Ownership is held by client ID, so a client that is deleted and created again with the same client ID owns its groups again.
A client cannot take ownership of a group it did not create. Groups that no SCIM client created keep today's behaviour. With Okta, linking a push to an existing group is therefore refused, and the directory has to create the group.
Every member in a request is checked before anything changes, so one invalid member rejects the whole request. That includes a member who no longer exists in Keycloak. Service accounts and administrators cannot be listed, as today. Writes to one group are serialized with a row lock.
A read shows every member.
Storage is one new table, SCIM_GROUP_OWNER (group, client ID), removed with its group.
It is off by default behind two switches: an experimental feature scim-group-membership-claims, which requires scim-api, and a realm attribute scimGroupMembershipClaims. With either one off, the SCIM endpoints behave exactly as they do today.
Administrators and mappers
An owner's full PUT removes members that an administrator added. I'd like to follow the pattern Keycloak uses for organization groups and refuse membership changes to owned groups through the Admin REST API, in a separate PR. Identity provider and LDAP group mappers that would change an owned group would skip that change and log a warning, also in a separate PR. Until those land, the documentation states that the owner's next full PUT overwrites an administrator's change.
What exists
#55342 implements an earlier version of this proposal, which recorded which SCIM client added each member so that several clients and administrators could share one group. It was tested against a real Okta wizard app. Review found most of its problems in that per-client bookkeeping, and sharing one group between several directories looks uncommon, so I'd rework #55342 to the model above if it fits.
Questions for maintainers
Is exclusive ownership acceptable in core, as an experimental feature, or would you rather keep PUT restricted and leave this to extensions?
For administrators, should changes to owned groups be refused, as for organization groups, or allowed with the overwrite documented?
For identity provider and LDAP mappers, is skipping the change with a warning acceptable?
Is a realm attribute the right switch, or should it be a realm setting shown in the Admin Console?
AI assistance: the implementation and this write-up were prepared with Claude Code, an AI coding agent. I have reviewed them and will handle the discussion and review.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Today a SCIM
PUT /Groups/{id}that carriesmembersis refused, by design (#46216), and #53130 plans to accept members onPOSTwhile keepingPUTrestricted. I'd like to propose a way to acceptPUTsafely, and ask whether it fits.The problem
Okta applications built with the App Integration Wizard push groups only with
PUT, sending the full member list each time, and the integration cannot be switched toPATCH. As captured on #53130 (by me with a wizard app, and by @wparr-circle with the Okta Provisioning Agent), only an empty group can reach Keycloak today. Every later add gets a 400 and Okta puts the group in an error state, and removing the last member gets a 200 that changes nothing (#54530).Accepting
PUTwith plain replace semantics would fix Okta and cause a new problem. A replace removes everyone the caller did not list. That includes members an administrator added in Keycloak, and members another SCIM client added to the same group. I assume this is part of whyPUTwas restricted.The proposal
The SCIM client that creates a group owns it, and only that client changes the group's members. The client is the one the access token was issued to. The membership is what the owner last sent.
For example, Okta creates Finance with Alice and Bob, so Okta owns Finance. Okta then sends a
PUTlisting only Alice, and Bob leaves the group. Another SCIM client that tries to add to, remove from, replace or delete Finance gets a 403.This matches how Okta describes group push itself: once a group is pushed, Okta becomes the group source.
The rules:
POST /Groupswithmemberscreates the group with those members, and the calling client becomes its owner.PUTa full member list (members not listed leave),PATCHadd,removeandreplace, including Entra'sremovewith avaluelist (Remove the SCIM group members or user groups listed in a PATCH remove value #55310), andDELETE. Any other SCIM client gets a 403 for all of them, including a delete of a group that has an owned group below it.groupson/Userscannot add or remove a membership of an owned group (400,mutability), as RFC 7643 section 4.1.2 describes, so an owned group has one write path.Storage is one new table,
SCIM_GROUP_OWNER(group, client ID), removed with its group.It is off by default behind two switches: an experimental feature
scim-group-membership-claims, which requiresscim-api, and a realm attributescimGroupMembershipClaims. With either one off, the SCIM endpoints behave exactly as they do today.Administrators and mappers
An owner's full
PUTremoves members that an administrator added. I'd like to follow the pattern Keycloak uses for organization groups and refuse membership changes to owned groups through the Admin REST API, in a separate PR. Identity provider and LDAP group mappers that would change an owned group would skip that change and log a warning, also in a separate PR. Until those land, the documentation states that the owner's next fullPUToverwrites an administrator's change.What exists
#55342 implements an earlier version of this proposal, which recorded which SCIM client added each member so that several clients and administrators could share one group. It was tested against a real Okta wizard app. Review found most of its problems in that per-client bookkeeping, and sharing one group between several directories looks uncommon, so I'd rework #55342 to the model above if it fits.
Questions for maintainers
PUTrestricted and leave this to extensions?Related: #46216, #53130, #54530, #52752, #55310, #55341, #55342.
AI assistance: the implementation and this write-up were prepared with Claude Code, an AI coding agent. I have reviewed them and will handle the discussion and review.
All reactions