Skip to content

Add Client resource type and scopes to authorization schema - #6

Open
ShashankFC wants to merge 1 commit into
feature-clients-authz-baselinefrom
feature-clients-authz-implementation
Open

Add Client resource type and scopes to authorization schema#6
ShashankFC wants to merge 1 commit into
feature-clients-authz-baselinefrom
feature-clients-authz-implementation

Conversation

@ShashankFC

@ShashankFC ShashankFC commented Jan 22, 2026

Copy link
Copy Markdown

Test 5nnn## Summary by CodeRabbitnn## Release Notesnn* New Featuresn * Added fine-grained authorization support for client management operations with granular permission scopes including configure, manage, view, and role mapping capabilities.n * Administrators can now assign detailed access controls for client and client scope operations, enabling better permission delegation and compliance.nn✏️ Tip: You can customize this high-level summary in your review settings.nnn---nReplicated from ai-code-review-evaluation/keycloak-coderabbit#5


Note

High Risk
Touches admin authorization/permission evaluation for client management, which is security-critical; incorrect scope evaluation could over- or under-grant access even though it is feature-flagged for FGAP v2.

Overview
Adds a new Clients resource type to the admin-permissions authorization schema, introducing client-specific scopes (configure, manage, view, and role-mapping variants) and the ability to resolve/create authz resources for client IDs.

Implements FGAP v2 client permission evaluation via new ClientPermissionsV2, wires it into MgmtPermissionsV2, and expands the test suite to cover per-client vs all-clients permissions, configure/manage/view behavior, and role-mapping/composite role scenarios. Listener cleanup logic is also gated behind the ADMIN_FINE_GRAINED_AUTHZ feature flag.

Written by Cursor Bugbot for commit 7e55408. Configure here.

…valuation implementation for ClientsPermissionsV2

Closes #35564

Signed-off-by: Martin Kanis <mkanis@redhat.com>
@ShashankFC

Copy link
Copy Markdown
Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

}
});

return granted;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getClientsWithPermission won't find individual client resources

Medium Severity

getClientsWithPermission calls resourceStore.findByType(server, "Clients", ...), but individual client resources created by getOrCreateResource never have their type set (no resource.setType(resourceType) call). Only the "all-clients" type-level resource (named "Clients") has type "Clients". So this method can never return individual client IDs — it either returns an empty set or a set containing the string "Clients", which is not a valid client ID. Callers like AvailableRoleMappingResource.getRoleIdsWithPermissions pass these to realm.getClientById(cid), which would return null and cause an NPE.

Additional Locations (1)

Fix in Cursor Fix in Web

return attributes;
}
};
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused private method getEvaluationContext is dead code

Low Severity

The private method getEvaluationContext is never called anywhere in ClientPermissionsV2. It appears to have been copied from the parent class's canExchangeTo method, but canExchangeTo in V2 throws UnsupportedOperationException. This dead code also pulls in several unused imports (Scope, EvaluationContext, TOKEN_EXCHANGE, etc.).

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants