fix: add admin-permissions client to isInternal denylist (FGAP V2) [FaaFyfxR9WAQrL7FcAgEHJvztd8cVMxvjHRS55rw1nwH] - #51631
Open
waterWang wants to merge 1 commit into
Conversation
…aaFyfxR9WAQrL7FcAgEHJvztd8cVMxvjHRS55rw1nwH] Closes keycloak#51630 ClientPermissions.isInternal only denylisted realm-management and -realm suffix clients. The admin-permissions client (the resource server holding the realm's FGAP V2 model) was not in that list, allowing a delegated admin with Clients:manage FGAP permission to update and disable it. Added a Constants.ADMIN_PERMISSIONS_CLIENT_ID check before the existing realm-specific checks so it's treated as internal in all realms.
Contributor
There was a problem hiding this comment.
Pull request overview
Protects Keycloak’s FGAP V2 admin-permissions client from delegated client-management operations.
Changes:
- Classifies
admin-permissionsas an internal client. - Blocks
canManageandcanConfigureauthorization paths.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| return false; | ||
| } | ||
|
|
||
| if (Constants.ADMIN_PERMISSIONS_CLIENT_ID.equals(client.getClientId())) { |
Comment on lines
+724
to
+726
| if (Constants.ADMIN_PERMISSIONS_CLIENT_ID.equals(client.getClientId())) { | ||
| return true; | ||
| } |
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.
Summary
ClientPermissions.isInternalonly denylisted therealm-managementclient (and, in the master realm, client IDs ending in-realm). Theadmin-permissionsclient — the resource server holding the realm's entire FGAP V2 model — was not in that list.Fix
Added a
Constants.ADMIN_PERMISSIONS_CLIENT_IDcheck before the existing realm-specific branches soadmin-permissionsis treated as internal in all realms (both admin/master and non-admin).Why this works
isInternalis called fromcanManage(ClientModel)andcanConfigure(ClientModel)— both returnfalsefor internal clients, preventing FGAPClients:managefrom overriding the block.getAccessmethod already special-casesadmin-permissions(returnsmanage: false), butcanManagedid not agree — this fix aligns enforcement with the access report.Testing
PermissionRESTTestalready validates that users withmanage-clientscannot create permissions onadmin-permissionsclient.REALM_MANAGEMENT_CLIENT_ID.Closes #51630