-
Notifications
You must be signed in to change notification settings - Fork 0
Automated Test: feature-groups-authz-implementation #315
Closed
admin-coderabbit
wants to merge
1
commit into
feature-groups-authz-baseline
from
feature-groups-authz-implementation
+831
−126
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -16,6 +16,8 @@ | |||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||
| package org.keycloak.services.resources.admin.permissions; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| import org.keycloak.authorization.AdminPermissionsSchema; | ||||||||||||||||||||||||||
| import org.keycloak.models.AdminRoles; | ||||||||||||||||||||||||||
| import org.keycloak.models.GroupModel; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| import java.util.Map; | ||||||||||||||||||||||||||
|
|
@@ -26,41 +28,121 @@ | |||||||||||||||||||||||||
| * @version $Revision: 1 $ | ||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||
| public interface GroupPermissionEvaluator { | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||
| * Returns {@code true} if the caller has at least one of {@link AdminRoles#QUERY_GROUPS}, | ||||||||||||||||||||||||||
| * {@link AdminRoles#MANAGE_USERS} or {@link AdminRoles#VIEW_USERS} roles. | ||||||||||||||||||||||||||
| * <p/> | ||||||||||||||||||||||||||
| * For V2 only: Also if it has a permission to {@link AdminPermissionsSchema#VIEW} or | ||||||||||||||||||||||||||
| * {@link AdminPermissionsSchema#MANAGE} groups. | ||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||
| boolean canList(); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||
| * Throws ForbiddenException if {@link #canList()} returns {@code false}. | ||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||
| void requireList(); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||
| * Returns {@code true} if the caller has {@link AdminRoles#MANAGE_USERS} role. | ||||||||||||||||||||||||||
| * <p/> | ||||||||||||||||||||||||||
| * Or if it has a permission to {@link AdminPermissionsSchema#MANAGE} the group. | ||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||
| boolean canManage(GroupModel group); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||
| * Throws ForbiddenException if {@link #canManage(GroupModel)} returns {@code false}. | ||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||
| void requireManage(GroupModel group); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||
| * Returns {@code true} if the caller has one of {@link AdminRoles#MANAGE_USERS} or | ||||||||||||||||||||||||||
| * {@link AdminRoles#VIEW_USERS} roles. | ||||||||||||||||||||||||||
| * <p/> | ||||||||||||||||||||||||||
| * Or if it has a permission to {@link AdminPermissionsSchema#VIEW} or | ||||||||||||||||||||||||||
| * {@link AdminPermissionsSchema#MANAGE} the group. | ||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||
| boolean canView(GroupModel group); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||
| * Throws ForbiddenException if {@link #canView(GroupModel)} returns {@code false}. | ||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||
| void requireView(GroupModel group); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||
| * Returns {@code true} if the caller has {@link AdminRoles#MANAGE_USERS} role. | ||||||||||||||||||||||||||
| * <p/> | ||||||||||||||||||||||||||
| * For V2 only: Also if it has permission to {@link AdminPermissionsSchema#VIEW} or | ||||||||||||||||||||||||||
| * {@link AdminPermissionsSchema#MANAGE} groups. | ||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||
| boolean canManage(); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||
| * Throws ForbiddenException if {@link #canManage()} returns {@code false}. | ||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||
| void requireManage(); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||
| * Returns {@code true} if the caller has one of {@link AdminRoles#MANAGE_USERS} or | ||||||||||||||||||||||||||
| * {@link AdminRoles#VIEW_USERS} roles. | ||||||||||||||||||||||||||
| * <p/> | ||||||||||||||||||||||||||
| * Or if it has a permission to {@link AdminPermissionsSchema#VIEW} or | ||||||||||||||||||||||||||
| * {@link AdminPermissionsSchema#MANAGE} groups. | ||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||
| boolean canView(); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||
| * Throws ForbiddenException if {@link #canView()} returns {@code false}. | ||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||
| void requireView(); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| boolean getGroupsWithViewPermission(GroupModel group); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||
| * Throws ForbiddenException if {@link #canViewMembers(GroupModel)} returns {@code false}. | ||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||
| void requireViewMembers(GroupModel group); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||
| * Returns {@code true} if {@link UserPermissionEvaluator#canManage()} evaluates to {@code true}. | ||||||||||||||||||||||||||
| * <p/> | ||||||||||||||||||||||||||
| * Or if it has a permission to {@link AdminPermissionsSchema#MANAGE_MEMBERS} of the group. | ||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||
| boolean canManageMembers(GroupModel group); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||
| * Returns {@code true} if the caller has one of {@link AdminRoles#MANAGE_USERS} role. | ||||||||||||||||||||||||||
| * <p/> | ||||||||||||||||||||||||||
| * Or if it has a permission to {@link AdminPermissionsSchema#MANAGE} the group or | ||||||||||||||||||||||||||
| * {@link AdminPermissionsSchema#MANAGE_MEMBERSHIP} of the group. | ||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||
| boolean canManageMembership(GroupModel group); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||
| * Returns {@code true} if {@link UserPermissionEvaluator#canView()} evaluates to {@code true}. | ||||||||||||||||||||||||||
| * <p/> | ||||||||||||||||||||||||||
| * Or if it has a permission to {@link AdminPermissionsSchema#VIEW_MEMBERS} or | ||||||||||||||||||||||||||
| * {@link AdminPermissionsSchema#MANAGE_MEMBERS} of the group. | ||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||
| boolean canViewMembers(GroupModel group); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||
| * Throws ForbiddenException if {@link #canManageMembership(GroupModel)} returns {@code false}. | ||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||
| void requireManageMembership(GroupModel group); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||
| * Throws ForbiddenException if {@link #canManageMembership(GroupModel)} returns {@code false}. | ||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||
| void requireManageMembers(GroupModel group); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||
| * Returns Map with information what access the caller for the provided group has. | ||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||
| Map<String, Boolean> getAccess(GroupModel group); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| Set<String> getGroupsWithViewPermission(); | ||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||
| * If {@link UserPermissionEvaluator#canView()} evaluates to {@code true}, returns empty set. | ||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||
| * @return Stream of IDs of groups with view permission. | ||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||
| Set<String> getGroupIdsWithViewPermission(); | ||||||||||||||||||||||||||
|
Comment on lines
+142
to
+147
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Return type in Javadoc should match Set. 📝 Javadoc fix- * `@return` Stream of IDs of groups with view permission.
+ * `@return` Set of IDs of groups with view permission.📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Javadoc points to the wrong predicate for requireManageMembers.
Line 132 should reference
canManageMembers, notcanManageMembership.📝 Javadoc fix
📝 Committable suggestion
🤖 Prompt for AI Agents