Add Client resource type and scopes to authorization schema - #6
Open
ShashankFC wants to merge 1 commit into
Open
Add Client resource type and scopes to authorization schema#6ShashankFC wants to merge 1 commit into
ShashankFC wants to merge 1 commit into
Conversation
…valuation implementation for ClientsPermissionsV2 Closes #35564 Signed-off-by: Martin Kanis <mkanis@redhat.com>
There was a problem hiding this comment.
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
CLIENTSresource type with scopes:configure,manage,view,map-roles,map-roles-client-scope, andmap-roles-composite - Implements
ClientPermissionsV2class 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); |
There was a problem hiding this comment.
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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Test 5
Summary by CodeRabbit
Release Notes
✏️ Tip: You can customize this high-level summary in your review settings.
Replicated from ai-code-review-evaluation/keycloak-coderabbit#5