DeepSeek V4.1 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 Haiku 5.5.
- Gold bugs found
- 4 of 8
- Comments published
- 6
- Comments matching a bug
- 4
- Comments not matching
- 2
- Cost of this PR
- $0.323
Published comments (6)
All-clients grants ignored when per-client resource exists — Any client with its own resource loses the grants an admin holds on the "Clients" type resource, so all-clients `manage`, `configure` and `view` silently stop applying. Evaluate the type resource as well and fall back to it instead of consulting it only when `resourceStore.findByName` returns null.
getClientsWithPermission matches only type resource, not per-client grants — The per-client resources from `AdminPermissionsSchema.getOrCreateResource` carry no type, so `findByType` returns only the literal "Clients" resource and omits every real grant, leaving `getRoleIdsWithPermissions` with a null client id. Iterate the realm's clients and check `hasPermission` on each instead.
canExchangeTo throws UnsupportedOperationException on token exchange path — `AbstractTokenExchangeProvider` calls `canExchangeTo` on every cross-client exchange, so enabling V2 turns each one into an uncaught exception and HTTP 500 instead of a 403. Return `false` or delegate to the existing evaluation, including the inherited 2-arg overload.
Client removal fails when both fine-grained authz features are enabled — With V1 and V2 both enabled, the `ClientRemovedEvent` branch still reaches `ClientPermissionsV2.setPermissionsEnabled` and throws, so deleting a client returns 500. Skip that branch when `ADMIN_FINE_GRAINED_AUTHZ_V2` is on, since V2 needs no permission cleanup. **Also found in:** - `services/src/main/java/org/keycloak/services/resources/admin/permissions/MgmtPermissionsV2.java:63-68`
canView(ClientModel) issues redundant per-client permission checks — `ClientsResource.getClients` calls `canView` per client, so a realm listing runs up to four resource lookups and policy evaluations each, with the type-level result never cached. Check `hasPermission(scope)` once and evaluate the client scopes in a single pass.
Missing null check on fallback resource before evaluation — When the `getResourceTypeResource` fallback also returns null, `root.evaluatePermission` dereferences a null `resource` and throws. Return `false` before the evaluation when `resource` is null. **Also found in:** - `services/src/main/java/org/keycloak/services/resources/admin/permissions/ClientPermissionsV2.java:215-222` - `services/src/main/java/org/keycloak/services/resources/admin/permissions/ClientPermissionsV2.java:214-222`