Kimi K3.1 Pro · Balanced
add-client-resource-type-and-scopes-to-authorization-schema-keycloak
Keycloak · Java · L · 300–799 lines · 5 files
The normal review, with one generalist agent. Judge: Claude Haiku 5.5.
- Gold bugs found
- 6 of 8
- Comments published
- 9
- Comments matching a bug
- 6
- Comments not matching
- 3
- Cost of this PR
- $1.952
Published comments (9)
Existing realms lack the Clients resource and scopes after upgrade — Add an upgrade or migration path that initializes the new resource and scopes on existing resource servers.
Client deletion skips V2 permission cleanup and breaks when V1 is also enabled — Client deletion has no working V2 cleanup path: with only V2 enabled this V1 guard skips the event and leaves per-client resources and policies behind, while enabling V1 and V2 makes `management(...).clients()` return the V2 evaluator whose `setPermissionsEnabled` throws `UnsupportedOperationException`. Implement V2 resource and policy cleanup independently of the legacy V1 `setPermissionsEnabled` path.
All-clients VIEW grant bypasses client-specific VIEW denials — A positive all-clients VIEW permission makes `canView()` return true before the client-specific resource is evaluated, so a negative per-client VIEW permission cannot deny access to that client. Evaluate the specific resource before accepting the global grant, preserving the override semantics used by `UserPermissionsV2`.
canView() ignores the global MANAGE permission — `canView()` checks only the global VIEW scope even though global MANAGE is treated as view elsewhere; an administrator with only all-clients MANAGE can fail `requireListClientScopes()` or receive an empty `/client-scopes` result while `canManageClientScopes()` is true. Include MANAGE in the global view decision or align `canViewClientScopes()` and `canListClientScopes()` with `canView(ClientScopeModel)`.
Client permission search skips untyped per-client resources — This search relies on resource type `Clients`, but `AdminPermissionsSchema.getOrCreateResource` never calls `setType` for per-client resources, so individual map-roles-composite grants produce no client IDs and `AvailableRoleMappingResource` omits their roles. Populate the resource type when creating client resources or query per-client resources without relying on a type they do not have.
Type-level Clients resource is returned as a client ID, causing an NPE — The all-clients schema resource itself has type and name `Clients`, so a global map-roles-composite grant makes this method return `Clients` as a client ID; `AvailableRoleMappingResource` then dereferences `realm.getClientById("Clients")` and throws a null-pointer exception. Exclude or expand the type-level resource instead of adding its name to the client ID set.
When any client-specific resource exists, `hasPermission` evaluates only that resource and never… — Evaluate the all-clients grant when the specific resource has no decision for the requested scope while retaining explicit client-specific denials.
Client permission resources have no display name — Add Clients handling that returns the client ID for individual resources and an all-clients label for the type resource.
With `ADMIN_FINE_GRAINED_AUTHZ_V2` enabled, every token exchange to a different target client… — Implement the V2 evaluation using the authorized client and token context, or provide a non-throwing compatibility path until V2 token-exchange permissions are supported.