Skip to content

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

Open
akshayutture-augment 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
akshayutture-augment wants to merge 1 commit into
feature-clients-authz-baselinefrom
feature-clients-authz-implementation

Conversation

@akshayutture-augment

@akshayutture-augment akshayutture-augment commented Nov 17, 2025

Copy link
Copy Markdown

No description provided.

…valuation implementation for ClientsPermissionsV2

Closes #35564

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

@augmentcode augmentcode 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.

Review completed. 4 suggestions posted.

Comment augment review to trigger a new review at any time.

RealmModel realm;
if (role.getContainer() instanceof ClientModel) {
realm = ((ClientModel)role.getContainer()).getRealm();
if (Profile.isFeatureEnabled(Profile.Feature.ADMIN_FINE_GRAINED_AUTHZ)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The event listener is gated by ADMIN_FINE_GRAINED_AUTHZ, but elsewhere V2 logic (e.g., evaluator selection and schema enablement) uses ADMIN_FINE_GRAINED_AUTHZ_V2; consider using the same V2 flag here to avoid missing permission cleanup when V2 is enabled.

🤖 Was this useful? React with 👍 or 👎


resourceStore.findByType(server, AdminPermissionsSchema.CLIENTS_RESOURCE_TYPE, resource -> {
if (hasGrantedPermission(resource, scope)) {
granted.add(resource.getName());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This collects all resources of type "Clients" and adds resource.getName(), which will also include the type resource named "Clients"; consider excluding the type resource so the returned set contains only client IDs.

🤖 Was this useful? React with 👍 or 👎

ResourceServer server = root.realmResourceServer();
if (server == null) return false;

Resource resource = resourceStore.findByName(server, client.getId(), server.getId());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The owner parameter in findByName uses server.getId(), but resources are created with owner set to resourceServer.getClientId; this mismatch can cause lookups to fail and skip per-client permissions.

🤖 Was this useful? React with 👍 or 👎

ResourceServer server = root.realmResourceServer();
if (server == null) return false;

Resource resource = resourceStore.findByName(server, AdminPermissionsSchema.CLIENTS_RESOURCE_TYPE, server.getId());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Using findByName with an explicit owner (server.getId()) for the "Clients" resource may not match how the type resource is created; this can incorrectly return null and deny permissions.

🤖 Was this useful? React with 👍 or 👎

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