-
Notifications
You must be signed in to change notification settings - Fork 0
Automated Test: feature-clients-authz-implementation #313
Closed
admin-coderabbit
wants to merge
1
commit into
feature-clients-authz-baseline
from
feature-clients-authz-implementation
+866
−138
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ | |
| */ | ||
| package org.keycloak.services.resources.admin.permissions; | ||
|
|
||
| import org.keycloak.models.AdminRoles; | ||
| import org.keycloak.models.ClientModel; | ||
| import org.keycloak.models.ClientScopeModel; | ||
|
|
||
|
|
@@ -31,54 +32,161 @@ public interface ClientPermissionEvaluator { | |
|
|
||
| void setPermissionsEnabled(ClientModel client, boolean enable); | ||
|
|
||
| /** | ||
| * Throws ForbiddenException if {@link #canListClientScopes()} returns {@code false}. | ||
| */ | ||
| void requireListClientScopes(); | ||
|
|
||
| /** | ||
| * Returns {@code true} if the caller has {@link org.keycloak.models.AdminRoles#MANAGE_CLIENTS} role. | ||
| * <p/> | ||
| * For V2 only: Also if it has permission to {@link org.keycloak.authorization.AdminPermissionsSchema#MANAGE}. | ||
| */ | ||
| boolean canManage(); | ||
|
|
||
| /** | ||
| * Throws ForbiddenException if {@link #canManage()} returns {@code false}. | ||
| */ | ||
| void requireManage(); | ||
|
|
||
| /** | ||
| * Returns {@code true} if the caller has {@link org.keycloak.models.AdminRoles#MANAGE_CLIENTS} role. | ||
| * <p/> | ||
| * For V2 only: Also if it has permission to {@link org.keycloak.authorization.AdminPermissionsSchema#MANAGE}. | ||
| */ | ||
| boolean canManageClientScopes(); | ||
|
|
||
| /** | ||
| * Throws ForbiddenException if {@link #canManageClientScopes()} returns {@code false}. | ||
| */ | ||
| void requireManageClientScopes(); | ||
|
|
||
| /** | ||
| * Returns {@code true} if the caller has at least one of the {@link org.keycloak.models.AdminRoles#MANAGE_CLIENTS} or {@link org.keycloak.models.AdminRoles#VIEW_CLIENTS} roles. | ||
| * <p/> | ||
| * For V2 only: Also if it has permission to {@link org.keycloak.authorization.AdminPermissionsSchema#VIEW}. | ||
| */ | ||
| boolean canView(); | ||
|
|
||
| /** | ||
| * Returns {@code true} if {@link #canView()} returns {@code true}. | ||
| * <p/> | ||
| * Or if the caller has at least one of the {@link AdminRoles#QUERY_CLIENTS} or {@link AdminRoles#QUERY_USERS} roles. | ||
| */ | ||
| boolean canList(); | ||
|
|
||
| /** | ||
| * Returns {@code true} if {@link #canView()} returns {@code true}. | ||
| */ | ||
| boolean canViewClientScopes(); | ||
|
|
||
| /** | ||
| * Throws ForbiddenException if {@link #canList()} returns {@code false}. | ||
| */ | ||
| void requireList(); | ||
|
|
||
| /** | ||
| * Returns {@code true} if {@link #canView()} returns {@code true}. | ||
| * <p/> | ||
| * Or if the caller has {@link AdminRoles#QUERY_CLIENTS} role. | ||
| */ | ||
| boolean canListClientScopes(); | ||
|
|
||
| /** | ||
| * Returns {@code true} if {@link #canView()} returns {@code true}. | ||
| */ | ||
| void requireView(); | ||
|
|
||
| /** | ||
| * Returns {@code true} if {@link #canViewClientScopes()} returns {@code true}. | ||
| */ | ||
| void requireViewClientScopes(); | ||
|
Comment on lines
+100
to
103
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. JavaDoc incorrectly states "Returns true" for a void method. Similar to 📝 Proposed fix- /**
- * Returns {`@code` true} if {`@link` `#canViewClientScopes`()} returns {`@code` true}.
- */
+ /**
+ * Throws ForbiddenException if {`@link` `#canViewClientScopes`()} returns {`@code` false}.
+ */
void requireViewClientScopes();🤖 Prompt for AI Agents |
||
|
|
||
| /** | ||
| * Returns {@code true} if the caller has {@link org.keycloak.models.AdminRoles#MANAGE_CLIENTS} role. | ||
| * <p/> | ||
| * Or if the caller has a permission to {@link AdminPermissionManagement#MANAGE_SCOPE} the client. | ||
| * <p/> | ||
| * For V2 only: Also if the caller has a permission to {@link org.keycloak.authorization.AdminPermissionsSchema#MANAGE} all clients. | ||
| */ | ||
| boolean canManage(ClientModel client); | ||
|
|
||
| /** | ||
| * Returns {@code true} if {@link #canManage(ClientModel)} returns {@code true}. | ||
| * <p/> | ||
| * Or if the caller has a permission to {@link ClientPermissionManagement#CONFIGURE_SCOPE} the client. | ||
| * <p/> | ||
| * For V2 only: Also if the caller has a permission to {@link org.keycloak.authorization.AdminPermissionsSchema#CONFIGURE} all clients. | ||
| */ | ||
| boolean canConfigure(ClientModel client); | ||
|
|
||
| /** | ||
| * Throws ForbiddenException if {@link #canConfigure(ClientModel)} returns {@code false}. | ||
| */ | ||
| void requireConfigure(ClientModel client); | ||
|
|
||
| /** | ||
| * Throws ForbiddenException if {@link #canManage(ClientModel)} returns {@code false}. | ||
| */ | ||
| void requireManage(ClientModel client); | ||
|
|
||
| /** | ||
| * Returns {@code true} if {@link #canView()} or {@link #canConfigure(ClientModel)} returns {@code true}. | ||
| * <p/> | ||
| * Or if the caller has a permission to {@link AdminPermissionManagement#VIEW_SCOPE} the client. | ||
| * <p/> | ||
| * For V2 only: Also if the caller has a permission to {@link org.keycloak.authorization.AdminPermissionsSchema#VIEW} all clients. | ||
| */ | ||
| boolean canView(ClientModel client); | ||
|
|
||
| /** | ||
| * Throws ForbiddenException if {@link #canView(ClientModel)} returns {@code false}. | ||
| */ | ||
| void requireView(ClientModel client); | ||
|
|
||
| /** | ||
| * Returns {@code true} if the caller has {@link org.keycloak.models.AdminRoles#MANAGE_CLIENTS} role. | ||
| * <p/> | ||
| * For V2 only: Also if it has permission to {@link org.keycloak.authorization.AdminPermissionsSchema#MANAGE}. | ||
| */ | ||
| boolean canManage(ClientScopeModel clientScope); | ||
|
|
||
| /** | ||
| * Throws ForbiddenException if {@link #canManage(ClientScopeModel)} returns {@code false}. | ||
| */ | ||
| void requireManage(ClientScopeModel clientScope); | ||
|
|
||
| /** | ||
| * Returns {@code true} if the caller has at least one of the {@link org.keycloak.models.AdminRoles#VIEW_CLIENTS} or {@link org.keycloak.models.AdminRoles#MANAGE_CLIENTS} roles. | ||
| * <p/> | ||
| * For V2 only: Also if it has permission to {@link org.keycloak.authorization.AdminPermissionsSchema#VIEW} or {@link org.keycloak.authorization.AdminPermissionsSchema#MANAGE}. | ||
| */ | ||
| boolean canView(ClientScopeModel clientScope); | ||
|
|
||
| /** | ||
| * Throws ForbiddenException if {@link #canView(ClientScopeModel)} returns {@code false}. | ||
| */ | ||
| void requireView(ClientScopeModel clientScope); | ||
|
|
||
| /** | ||
| * Returns {@code true} if the caller has a permission to {@link ClientPermissionManagement#MAP_ROLES_SCOPE} for the client. | ||
| * <p/> | ||
| * For V2 only: Also if the caller has a permission to {@link org.keycloak.authorization.AdminPermissionsSchema#MAP_ROLES} for all clients. | ||
| */ | ||
| boolean canMapRoles(ClientModel client); | ||
|
|
||
| /** | ||
| * Returns {@code true} if the caller has a permission to {@link ClientPermissionManagement#MAP_ROLES_COMPOSITE_SCOPE} for the client. | ||
| * <p/> | ||
| * For V2 only: Also if the caller has a permission to {@link org.keycloak.authorization.AdminPermissionsSchema#MAP_ROLES_COMPOSITE} for all clients. | ||
| */ | ||
| boolean canMapCompositeRoles(ClientModel client); | ||
|
|
||
| /** | ||
| * Returns {@code true} if the caller has a permission to {@link ClientPermissionManagement#MAP_ROLES_CLIENT_SCOPE} for the client. | ||
| * <p/> | ||
| * For V2 only: Also if the caller has a permission to {@link org.keycloak.authorization.AdminPermissionsSchema#MAP_ROLES_CLIENT_SCOPE} for all clients. | ||
| */ | ||
| boolean canMapClientScopeRoles(ClientModel client); | ||
|
|
||
| Map<String, Boolean> getAccess(ClientModel client); | ||
|
|
||
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 incorrectly states "Returns true" for a void method.
The JavaDoc for
requireView()says "Returns {@codetrue} if..." but this method has avoidreturn type. Based on the pattern of otherrequireXxxmethods in this interface (e.g., lines 47-50, 59-62), this should say "Throws ForbiddenException if {@link#canView()} returns {@codefalse}."📝 Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents