Skip to content

Do not expose organization groups through the SCIM Users groups attribute - #51591

Merged
pedroigor merged 1 commit into
keycloak:mainfrom
sventorben:scim-org-groups-user-attribute
Aug 11, 2026
Merged

Do not expose organization groups through the SCIM Users groups attribute#51591
pedroigor merged 1 commit into
keycloak:mainfrom
sventorben:scim-org-groups-user-attribute

Conversation

@sventorben

Copy link
Copy Markdown
Contributor

Closes #51590

Organization groups — and the organization's internal backing group — were exposed through the groups attribute of the SCIM Users resource.

AbstractUserModelSchema.getAttributeValue returned model.getGroupsStream() filtered only by canViewGroup, which resolves to GroupPermissionsV2.canView(group) and short-circuits to true for any caller holding view-users or manage-users. There was no group-type check on that path. Since organization membership is itself a membership in the organization's internal group, both that group and any organization groups were returned.

The same boundary is already enforced for the Groups resource (#50310 / #50311) and on the SCIM user write path in UserCoreModelSchema.checkGroupMembershipPermission, which throws "Cannot access organization related group via non Organization API.". This aligns the read path with those.

The predicate used by the write path is extracted into AbstractUserModelSchema.isOrganizationGroup and reused on both sides, so the two cannot drift apart. It matches the existing behaviour exactly (Type.ORGANIZATION and a non-null organization); both the internal group and organization groups carry the organization relationship, set in JpaOrganizationProvider on organization creation and in createGroup respectively.

Added UserTest#testOrganizationGroupsNotExposedOnUser, which puts a user in a realm group, an organization, and an organization group, then asserts that only the realm group is returned by GET /Users/{id}?attributes=groups.

Note for reviewers: UserResourceTypeProvider.getAttributeExpression maps the SCIM groups filter onto UserGroupMembershipEntity.groupId without a type restriction, so a user can still be filtered by a known organization group id. That is a separate surface from serialization and is left out of this change — happy to follow up if you would like it covered here or in its own issue.

…bute

Closes keycloak#51590

Signed-off-by: Sven-Torben Janus <sven-torben.janus@conciso.de>
Copilot AI balanced review requested due to automatic review settings August 10, 2026 20:48
@sventorben
sventorben requested a review from a team as a code owner August 10, 2026 20:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Prevents organization-related groups from appearing in SCIM user group attributes.

Changes:

  • Filters organization groups during user serialization.
  • Reuses the same predicate for user group write validation.
  • Adds regression coverage for realm, organization, and backing groups.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
AbstractUserModelSchema.java Excludes organization groups from serialized memberships.
UserCoreModelSchema.java Reuses the organization-group predicate.
UserTest.java Verifies only realm groups are returned.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@pedroigor pedroigor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @sventorben ! Created #51614 as a follow-up.

@pedroigor
pedroigor merged commit 2c70277 into keycloak:main Aug 11, 2026
92 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SCIM: organization groups exposed via the groups attribute on Users

4 participants