Keycloak: findGroup ignores subgroups, so an admin group that is a subgroup resolves to nobody #987

Closed
opened 2026-10-24 16:12:56 +00:00 by Cordy · 1 comment
Owner

Found in the #985 research (research-985-4 §4.2).

What happens. findGroup (spaces.go:167-179) calls GET /groups?search=<name>&briefRepresentation=false and compares only the top-level results' names. Keycloak 24-26 returns the root of each match with the path down to it in subGroups (VERIFIED), so for a subgroup the top-level entry has another name and findGroup returns nil.

Effects (INFERRED from code).

  • GroupMembers (spaces.go:667-692) answers "unknown group, empty list" for an admin group that is a subgroup. Users & access shows the administrator list without that group's members and calls it complete (access.go:220-231).
  • Peering receiver-group expansion gets nobody.
  • The compare is substring search plus EqualFold, while sign-in compares exactly and case-sensitively.

GroupExists and UserGroupRefs already handle subgroups correctly; this is the one function that does not.

Fix (S). Walk subGroups recursively like GroupExists; for a value starting with / use group-by-path; compare exactly, as sign-in does.

Live test. Keycloak 26: create /org/cairn-admins with member anna, adminGroups: ["cairn-admins"] with full group path off, open Users & access: today anna is missing.

Found in the #985 research (research-985-4 §4.2). **What happens.** `findGroup` (`spaces.go:167-179`) calls `GET /groups?search=<name>&briefRepresentation=false` and compares only the **top-level** results' names. Keycloak 24-26 returns the root of each match with the path down to it in `subGroups` (VERIFIED), so for a subgroup the top-level entry has another name and `findGroup` returns nil. **Effects (INFERRED from code).** - `GroupMembers` (`spaces.go:667-692`) answers "unknown group, empty list" for an admin group that is a subgroup. Users & access shows the administrator list **without** that group's members and calls it complete (`access.go:220-231`). - Peering receiver-group expansion gets nobody. - The compare is substring search plus `EqualFold`, while sign-in compares exactly and case-sensitively. `GroupExists` and `UserGroupRefs` already handle subgroups correctly; this is the one function that does not. **Fix (S).** Walk `subGroups` recursively like `GroupExists`; for a value starting with `/` use `group-by-path`; compare exactly, as sign-in does. **Live test.** Keycloak 26: create `/org/cairn-admins` with member anna, `adminGroups: ["cairn-admins"]` with full group path off, open Users & access: today anna is missing.
Author
Owner

Fixed in v0.6.354 (PR #1004), live on both dogfoods. findGroup resolves a bare name to a top-level group only (exact, case-sensitive) and a /path value by group path. An admin group that is a subgroup is now written as its full path (for example /org/cairn-admins), and the admin list then resolves its members. Regression tests in the Keycloak fake. Closing.

Fixed in v0.6.354 (PR #1004), live on both dogfoods. `findGroup` resolves a bare name to a top-level group only (exact, case-sensitive) and a `/path` value by group path. An admin group that is a subgroup is now written as its full path (for example `/org/cairn-admins`), and the admin list then resolves its members. Regression tests in the Keycloak fake. Closing.
Cordy closed this issue 2026-10-25 21:29:30 +00:00
Sign in to join this conversation.
No labels
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Cordy/Cairn#987
No description provided.