Repository navigation
fix: improve realm_exists method by using a lightweight endpoint #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: IMIO/pas.plugins.kimug
Length of output: 7131
🏁 Script executed:
Repository: IMIO/pas.plugins.kimug
Length of output: 5541
🌐 Web query:
Keycloak users/count endpoint permissions view-users manage-users realm-management docs💡 Result:
To access the Keycloak users/count endpoint via the Admin REST API, a user must possess sufficient permissions granted through the realm-management client [1]. Permission Requirements: The
countoperation on the Users resource requires permissions equivalent to querying or viewing users [2]. Specifically, the evaluator for this resource requires that the caller has at least one of the following administrative roles, which are defined within the realm-management client [2][1]: 1. view-users: Allows an administrator to view all users and groups in the realm [3][4]. 2. manage-users: Provides broader access, including all privileges granted by view-users, as well as the ability to manage user memberships, roles, and groups [3][4]. 3. query-users: A more specific role that provides permission to search and query user information [4]. Technical Implementation: The UsersResource API class handles these requests, and the underlying logic (UserPermissionEvaluator) verifies that the caller has at least one of these roles [2][5][6]. If the feature is enabled, fine-grained authorization (FGAP) may also grant access if specific permissions are configured for the user resource [3][2]. In standard configurations, possessing the view-users or manage-users role is sufficient to successfully call the count endpoint [2][5]. If a user lacks these roles, the API will return a 403 Forbidden status [7]. Ensure that the service account or user account being used to authenticate the API call is mapped to at least one of these roles under the realm-management client for the respective realm [4][1].Citations:
🏁 Script executed:
Repository: IMIO/pas.plugins.kimug
Length of output: 17141
Use a check that matches the migration’s write path.
/users/countcan return 200 with only view/query-user privileges, but this flow later creates and updates users. Probe an endpoint that requires the same admin rights as the migration, or rename this method so it only promises user-count access.🤖 Prompt for AI Agents