Add Keycloak Group/Client Role lookups needed for cubecmp's project role-count endpoint - #101
Merged
Merged
Conversation
…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
force-pushed
the
shawn.hsu/list-client-role-users
branch
from
September 10, 2026 10:22
645b16c to
47d2a19
Compare
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>
arasHi87
approved these changes
Sep 11, 2026
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.
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 viaHasClientRole. Paginates via the sameFirst/Maxloop aspaginateGroups/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 wayGetOrCreateGroupPathdoes. Needed before listing that group's members for a read-only count.go-micro.dev/v5from v5.3.0 to v5.30.0, even though our own use of it (viamicro/plugins/v5/logger/zap) only ever needed v5.2.0+. v5.30.0 removed theutil/addrpackage that consumers still ongithub.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/GetGroupMembersfor the bulk lookup,GetGroup/GetOrCreateGroupPathfor the by-path lookup) -- newClientinterface entries only (mirrors gocloak's own methods, no implementation needed) plus a newHelpermethod each.Additional documentation