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

Copy link
Copy Markdown
Contributor

Test 5

Summary by CodeRabbit

Release Notes

  • New Features
    • Added fine-grained authorization support for client management operations with granular permission scopes including configure, manage, view, and role mapping capabilities.
    • Administrators can now assign detailed access controls for client and client scope operations, enabling better permission delegation and compliance.

✏️ Tip: You can customize this high-level summary in your review settings.


Replicated from ai-code-review-evaluation/keycloak-coderabbit#5

…valuation implementation for ClientsPermissionsV2

Closes #35564

Signed-off-by: Martin Kanis <mkanis@redhat.com>
@ShashankFC
ShashankFC requested a review from Copilot January 30, 2026 10:27

Copilot AI 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.

Pull request overview

This PR adds support for client resource types and scopes to the authorization schema, enabling fine-grained permission management for client operations.

Changes:

  • Adds CLIENTS resource type with scopes: configure, manage, view, map-roles, map-roles-client-scope, and map-roles-composite
  • Implements ClientPermissionsV2 class to handle client permission evaluation using the new authorization schema
  • Refactors test utilities to use static methods and centralize permission creation logic

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
server-spi-private/src/main/java/org/keycloak/authorization/AdminPermissionsSchema.java Adds CLIENTS resource type with associated scopes and client resolution logic
services/src/main/java/org/keycloak/services/resources/admin/permissions/ClientPermissionsV2.java Implements V2 permission checks for client operations using the new schema
services/src/main/java/org/keycloak/services/resources/admin/permissions/MgmtPermissionsV2.java Adds instantiation and management of ClientPermissionsV2
services/src/main/java/org/keycloak/services/resources/admin/permissions/ClientPermissionEvaluator.java Adds comprehensive documentation for client permission methods
services/src/main/java/org/keycloak/services/resources/admin/permissions/AdminPermissions.java Wraps event listener logic with feature flag check
tests/base/src/test/java/org/keycloak/tests/admin/authz/fgap/AbstractPermissionTest.java Refactors test utilities to static methods and adds helper methods for policy and permission creation
tests/base/src/test/java/org/keycloak/tests/admin/authz/fgap/PermissionClientTest.java Adds comprehensive tests for client permission scenarios
tests/base/src/test/java/org/keycloak/tests/admin/authz/fgap/PermissionRESTTest.java Updates method calls to pass client parameter
tests/base/src/test/java/org/keycloak/tests/admin/authz/fgap/UserResourceTypeEvaluationTest.java Refactors to use centralized helper methods and removes duplicate code
tests/base/src/test/java/org/keycloak/tests/admin/authz/fgap/UserResourceTypePermissionTest.java Updates method calls to pass client parameter

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}

UserPolicyRepresentation onlyMyAdminUserPolicy = createUserPolicy(realm, client, "Only My Admin User Policy", myadmin.getId());
createPermission(client, myadmin.getId(), AdminPermissionsSchema.USERS_RESOURCE_TYPE, Set.of(MAP_ROLES), onlyMyAdminUserPolicy);

Copilot AI Jan 30, 2026

Copy link

Choose a reason for hiding this comment

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

The constant AdminPermissionsSchema.USERS_RESOURCE_TYPE is used instead of the existing usersType field pattern. For consistency with line 76 where clientsType is defined, consider using a similar field usersType or use the constant directly everywhere.

Suggested change
createPermission(client, myadmin.getId(), AdminPermissionsSchema.USERS_RESOURCE_TYPE, Set.of(MAP_ROLES), onlyMyAdminUserPolicy);
createPermission(client, myadmin.getId(), usersType, Set.of(MAP_ROLES), onlyMyAdminUserPolicy);

Copilot uses AI. Check for mistakes.
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.

3 participants