8000 Align users/count visibility with the users list endpoint by edewit · Pull Request #55805 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Align users/count visibility with the users list endpoint - #55805

Open
edewit wants to merge 1 commit into
keycloak:mainfrom
edewit:fix/kc-55787
Open

edewit wants to merge 1 commit into
keycloak:mainfrom
edewit:fix/kc-55787

Conversation

@edewit
@edewit edewit commented Dec 4, 2026
Copy link
Copy Markdown
Contributor

Closes #55787

Restores the same visibility rules for GET /admin/realms/{realm}/users/count as for the users list, so callers with only query-users cannot use counts as an attribute oracle on default (non-FGAP) realms.

Decisions and assumptions:

  • Shared countUsers() helper: unrestricted when canView(), provider authz filters when FGAP v2 is enabled for the realm, group-scoped count for FGAP v1, otherwise 0 to match an empty list.
  • Regression coverage focuses on the default non-FGAP query-users path; existing FGAP count tests remain the check for fine-grained realms.

AI agents assisted with implementing this change from the issue description.

Callers without view permission on default (non-FGAP) realms were getting
unrestricted counts, which could disclose user attributes via filter oracles.

Closes keycloak#55787

Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
@edewit
ede 6870 wit marked this pull request as ready for review December 4, 2026 10:02
@edewit
edewit requested a review from a team as a code owner December 4, 2026 10:02
Copilot AI balanced review requested due to automatic review settings December 4, 2026 10:02
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.

🟢 Approval recommended

No active review issues are reported for the change aligning user counts with list visibility.

No open issues 🎉

What changed in this PR

Aligns user counts with list visibility, preventing query-users-only callers from inferring hidden user data on default realms.

Changes:

  • Centralizes permission-aware counting while preserving fine-grained authorization handling.
  • Adds regression tests for restricted callers and callers with view-users.
File Description
tests/​base/​src/​test/​java/​org/​keycloak/​tests/​admin/​user/​UserCountVisibilityTest.java Tests zero counts for restricted callers and accurate counts for authorized callers.
services/​src/​main/​java/​org/​keycloak/​services/​resources/​admin/​UsersResource.java Routes count requests through a shared visibility-aware helper.

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

2 participants

0