Skip to content

Add Keycloak Group/Client Role lookups needed for cubecmp's project role-count endpoint - #101

Merged
github-actions[bot] merged 4 commits into
developfrom
shawn.hsu/list-client-role-users
Sep 11, 2026
Merged

github-actions[bot] merged 4 commits into
developfrom
shawn.hsu/list-client-role-users

Conversation

@ambersun1234

@ambersun1234 ambersun1234 commented Sep 10, 2026

Copy link
Copy Markdown

What type of PR is this?

/kind feature

What this PR does / why we need it

cubecmp's #1356 (per-project user role-count summary endpoint) needs three things this helper didn't expose yet:

  • Helper.GetUsersByClientRoleName(realm, clientID, roleName string) ([]*gocloak.User, error) -- bulk lookup of every user holding a given Client Role, instead of checking one user at a time via HasClientRole. Paginates via the same First/Max loop as paginateGroups/paginateGroupMembers.
  • Helper.GetGroupByPath(realm, path string) (*gocloak.Group, error) -- resolves a Group's ID from its full path (e.g. /cubecmp/{project}/admin) without walking/creating the path the way GetOrCreateGroupPath does. Needed before listing that group's members for a read-only count.
  • A pin fix: the prior grouped Dependabot bump moved go-micro.dev/v5 from v5.3.0 to v5.30.0, even though our own use of it (via micro/plugins/v5/logger/zap) only ever needed v5.2.0+. v5.30.0 removed the util/addr package that consumers still on github.com/micro/plugins/v5/server/http@v1.0.2 (the latest available version of that plugin) need to compile -- there is no newer plugin release that drops the dependency. Any consumer bumping past the v5.30.0 commit breaks as a result; pinned back to v5.3.0.

No behavior change to any existing method.

Which issue(s) this PR fixes

Fixes #

Special notes for your reviewer

Both new methods mirror the exact shape of existing ones (HasClientRole/GetGroupMembers for the bulk lookup, GetGroup/GetOrCreateGroupPath for the by-path lookup) -- new Client interface entries only (mirrors gocloak's own methods, no implementation needed) plus a new Helper method each.

Additional documentation


@ambersun1234
ambersun1234 requested review from a team and raven-pan as code owners September 10, 2026 09:50
@ambersun1234 ambersun1234 self-assigned this Sep 10, 2026
…kups

HasClientRole only checks one user at a time -- a consumer that needs to
know which users out of a whole list hold a given Client Role would have
to call it once per user. Wraps gocloak's existing
GetUsersByClientRoleName instead, so the check becomes one call for the
whole role membership.

Paginates via the same First/Max loop as paginateGroups/
paginateGroupMembers, reusing groupsPageSize -- Keycloak's list endpoints
silently truncate to a server-side default page size when Max is unset,
same footgun those two already guard against.

Signed-off-by: Shawn Hsu <shawn.hsu@bigstack.co>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
go.mod was bumped to require go 1.26.0 (2026-09-07's minor-and-patch
dependency update), but ci.yaml still hard-pinned actions/setup-go to
1.25 -- GOTOOLCHAIN=local means it never auto-upgrades, so the mockery
step has failed with "go.mod requires go >= 1.26.0" on every PR since,
this one included. Switching to go-version-file avoids the same drift
happening again next time go.mod's Go version moves.

Signed-off-by: Shawn Hsu <shawn.hsu@bigstack.co>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@ambersun1234
ambersun1234 force-pushed the shawn.hsu/list-client-role-users branch from 645b16c to 47d2a19 Compare September 10, 2026 10:22
cubecmp needs to resolve a Group's ID from its full path (e.g.
/cubecmp/{project}/admin) before it can list that group's members,
without walking/creating the path like GetOrCreateGroupPath does.

Signed-off-by: Shawn Hsu <shawn.hsu@bigstack.co>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The prior dependabot bump (PR #90) moved go-micro.dev/v5 from v5.3.0
to v5.30.0 as part of an unrelated grouped minor/patch update, even
though our own use of it (via micro/plugins/v5/logger/zap) only ever
needed v5.2.0+. v5.30.0 removed the util/addr package that consumers
still on github.com/micro/plugins/v5/server/http@v1.0.2 (the latest
available version of that plugin) need to compile -- there is no
newer plugin release that drops the dependency. Any consumer bumping
past the v5.30.0 commit breaks as a result.

Signed-off-by: Shawn Hsu <shawn.hsu@bigstack.co>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@ambersun1234 ambersun1234 changed the title Add a bulk lookup for users holding a Keycloak Client Role Add Keycloak Group/Client Role lookups needed for cubecmp's project role-count endpoint Sep 10, 2026
@ambersun1234 ambersun1234 added the done Merge the pull request label Sep 11, 2026
@github-actions
github-actions Bot merged commit 117364b into develop Sep 11, 2026
6 checks passed
@github-actions
github-actions Bot deleted the shawn.hsu/list-client-role-users branch September 11, 2026 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

done Merge the pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants