GLM-5.3 · 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
- 3 of 8
- Comments published
- 4
- Comments matching a bug
- 3
- Comments not matching
- 1
- Cost of this PR
- $1.854
Published comments (4)
`MgmtPermissionsV2.clients()` breaks callers via `ClientPermissionsV2` V1 stubs — When both `ADMIN_FINE_GRAINED_AUTHZ` and its V2 are enabled, every client deletion fails: the `ClientRemovedEvent` handler in `AdminPermissions` calls `setPermissionsEnabled`, which `ClientPermissionsV2` stubs with `UnsupportedOperationException`; `ClientResource`'s V1 endpoints and `canExchangeTo` break likewise. Keep V1 semantics for these methods or gate the V1 callers on `!ADMIN_FINE_GRAINED_AUTHZ_V2`.
getClientsWithPermission: 'Clients' in result and per-client grants omitted — With a type-level grant, the result contains the literal `Clients` name, not a client ID, so `AvailableRoleMappingResource` NPEs on the null `getClientById` result; per-client resources, created typeless by `AdminPermissionsSchema.getOrCreateResource`, stay invisible to `findByType` and get omitted — a V1 regression. Skip the type resource and include per-client grants.
NPE when Clients type resource is missing in hasPermission(ClientModel, String) — Realms initialized before this change never get the `Clients` type resource, so `getResourceTypeResource` returns null and `policyStore.findByResource` NPEs; every client permission evaluation 500s for callers without realm-admin roles, though the sibling type-level method null-checks. Guard `resource == null`, and add a store migration creating missing type resources and scopes. **Also found in:** - `server-spi-private/src/main/java/org/keycloak/authorization/AdminPermissionsSchema.java:63-68`
Client-removal cleanup skipped when only ADMIN_FINE_GRAINED_AUTHZ_V2 is enabled — Since `ADMIN_FINE_GRAINED_AUTHZ_V2` is an independent feature, clients deleted under it permanently orphan their resources and referencing permissions; `getClientsWithPermission` then policy-evaluates every orphan on each restricted client listing, growing cost unboundedly. Handle `ClientRemovedEvent` for V2 by deleting the removed client's resource and referencing permissions.