GLM-5.3 Flash · Heavy
add-client-resource-type-and-scopes-to-authorization-schema-keycloak
Keycloak · Java · L · 300–799 lines · 5 files
The generalist plus 9 specialist lens agents in parallel, then the same verify and dedup steps. Judge: Claude Opus 5.5.
- Gold bugs found
- 3 of 15
- Comments published
- 5
- Comments matching a bug
- 3
- Comments not matching
- 2
- Cost of this PR
- $0.317
Published comments (5)
NPE in hasPermission when Clients type resource does not exist — When the realm's admin-permissions client predates this PR, `AdminPermissionsSchema.init` no-ops and `getResourceTypeResource` returns null, so `findByResource` throws an NPE and every client view or update turns into a 500. Add a null check returning false, mirroring the 1-arg `hasPermission`.
Client delete fails when both fine-grained authz versions enabled: V2 cleanup throws — When both feature flags are on, the handler in AdminPermissions.java selects `MgmtPermissionsV2` and `setPermissionsEnabled` throws, so deleting any client fails and rolls back. Make the guard skip cleanup when the V2 flag is active instead of checking the V1 flag. **Also found in:** - `services/src/main/java/org/keycloak/services/resources/admin/permissions/AdminPermissions.java:77-95` - `services/src/main/java/org/keycloak/services/resources/admin/permissions/AdminPermissions.java:77-96`
Per-client resource lacks type so all-clients policies are ignored in evaluation — An all-clients grant silently stops applying once any per-client permission for that client exists, because `AdminPermissionsSchema.getOrCreateResource` never sets a `type`, so `DefaultPolicyEvaluator` skips type-scoped policies. Set `AdminPermissionsSchema.CLIENTS_RESOURCE_TYPE` on the resource so those policies participate in evaluation. **Also found in:** - `services/src/main/java/org/keycloak/services/resources/admin/permissions/ClientPermissionsV2.java:136-144`
testMapRolesAndCompositesOnlyOneClient grants all scopes at once, masking wrong-scope regressions — Because every scope is granted at once, `ClientPermissionsV2` could evaluate the wrong scope and the test would still pass: negatives still throw and post-grant operations still succeed. Create one permission per scope (`MAP_ROLES`, then `MAP_ROLES_COMPOSITE`), or assert intermediate negative states between grants.
V2-enabled cleanup skipped: guard ignores ADMIN_FINE_GRAINED_AUTHZ_V2 — With V2 enabled and the old flag off, removal cleanup is silently skipped while V2 keeps creating per-object permission resources, so stale policies can re-apply to a future object reusing the id. If V2 doesn't clean this up elsewhere, include `ADMIN_FINE_GRAINED_AUTHZ_V2` in the guard.