diff --git a/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/Resources/IResourcePermissionChecker.cs b/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/Resources/IResourcePermissionChecker.cs index 383e49c527..4e8229d605 100644 --- a/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/Resources/IResourcePermissionChecker.cs +++ b/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/Resources/IResourcePermissionChecker.cs @@ -5,22 +5,55 @@ namespace Volo.Abp.Authorization.Permissions.Resources; public interface IResourcePermissionChecker { + /// + /// Checks if the given permission is granted for the given resource. + /// + /// The name of the permission. + /// The name of the resource. + /// Resource key + /// + /// True if the permission is granted. + /// Task IsGrantedAsync( string permissionName, string resourceName, string resourceKey ); + /// + /// Gets all permissions for the given resource. + /// + /// Resource name + /// Resource key + /// + /// A dictionary of permission names and their states. + /// Task> GetPermissionsAsync( string resourceName, string resourceKey ); + /// + /// Gets all granted permissions for the given resource. + /// + /// Resource name + /// Resource key + /// + /// An array of granted permission names. + /// Task GetGrantedPermissionsAsync( string resourceName, string resourceKey ); - + + /// + /// Retrieves the keys of resources for which the specified permission is granted. + /// + /// The name of the resource. + /// The name of the permission. + /// + /// An array of resource keys where the specified permission is granted. + /// Task GetGrantedResourceKeysAsync( string resourceName, string permissionName diff --git a/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/Resources/ResourcePermissionCheckerExtensions.cs b/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/Resources/ResourcePermissionCheckerExtensions.cs index bd54ef5eee..fa73aa428f 100644 --- a/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/Resources/ResourcePermissionCheckerExtensions.cs +++ b/framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/Resources/ResourcePermissionCheckerExtensions.cs @@ -5,6 +5,15 @@ namespace Volo.Abp.Authorization.Permissions.Resources; public static class ResourcePermissionCheckerExtensions { + /// + /// Checks if a specific permission is granted for a resource with a given key. + /// + /// The type of the resource. + /// The resource permission checker instance. + /// The name of the permission to check. + /// The resource instance to check permission for. + /// The unique key identifying the resource instance. + /// A task that represents the asynchronous operation. The task result contains a boolean value indicating whether the permission is granted. public static Task IsGrantedAsync( this IResourcePermissionChecker resourcePermissionChecker, string permissionName, @@ -23,7 +32,15 @@ public static class ResourcePermissionCheckerExtensions resourceKey.ToString()! ); } - + + /// + /// Retrieves a dictionary of permissions and their granted statuses for a specific resource. + /// + /// The type of the resource. + /// The resource permission checker instance. + /// The resource instance for which permissions are being checked. + /// The unique key identifying the resource instance. + /// A task that represents the asynchronous operation. The task result contains a dictionary where keys are permission names and values indicate whether the corresponding permission is granted. public static Task> GetPermissionsAsync( this IResourcePermissionChecker resourcePermissionChecker, TResource resource, @@ -39,7 +56,15 @@ public static class ResourcePermissionCheckerExtensions resourceKey.ToString()! ); } - + + /// + /// Retrieves the list of granted permissions for a specific resource with a given key. + /// + /// The type of the resource. + /// The resource permission checker instance. + /// The resource instance to retrieve permissions for. + /// The unique key identifying the resource instance. + /// A task that represents the asynchronous operation. The task result contains an array of strings representing the granted permissions. public static Task GetGrantedPermissionsAsync( this IResourcePermissionChecker resourcePermissionChecker, TResource resource, @@ -55,7 +80,15 @@ public static class ResourcePermissionCheckerExtensions resourceKey.ToString()! ); } - + + /// + /// Retrieves the keys of the resources granted a specific permission. + /// + /// The type of the resource. + /// The resource permission checker instance. + /// The resource instance to check granted permissions for. + /// The name of the permission to check. + /// A task that represents the asynchronous operation. The task result contains an array of strings representing the granted resource keys. public static Task GetGrantedResourceKeysAsync( this IResourcePermissionChecker resourcePermissionChecker, TResource resource, diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Authorization/Permissions/Resources/EntityResourcePermissionCheckerExtensions.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Authorization/Permissions/Resources/EntityResourcePermissionCheckerExtensions.cs index 9867bb68cb..6a3ff5e6b1 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Authorization/Permissions/Resources/EntityResourcePermissionCheckerExtensions.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Authorization/Permissions/Resources/EntityResourcePermissionCheckerExtensions.cs @@ -8,6 +8,14 @@ namespace Volo.Abp.Authorization.Permissions.Resources; public static class EntityResourcePermissionCheckerExtensions { + /// + /// Checks if the specified permission is granted for the given entity. + /// + /// The type of the entity. + /// The resource permission checker instance. + /// The name of the permission to check. + /// The entity for which the permission is being checked. + /// A task that represents the asynchronous operation. The task result is a boolean indicating whether the permission is granted. public static Task IsGrantedAsync( this IResourcePermissionChecker resourcePermissionChecker, string permissionName, @@ -25,7 +33,14 @@ public static class EntityResourcePermissionCheckerExtensions entity.GetKeys().JoinAsString(",") ); } - + + /// + /// Retrieves a dictionary of permissions and their granted status for the specified entity. + /// + /// The type of the entity. + /// The resource permission checker instance. + /// The entity for which the permissions are being retrieved. + /// A dictionary where the keys are permission names and the values are booleans indicating whether the permission is granted. public static Task> GetPermissionsAsync( this IResourcePermissionChecker resourcePermissionChecker, TEntity entity @@ -40,7 +55,14 @@ public static class EntityResourcePermissionCheckerExtensions entity.GetKeys().JoinAsString(",") ); } - + + /// + /// Retrieves an array of granted permissions for a specific entity. + /// + /// The type of the entity. + /// The resource permission checker instance. + /// The entity for which the permissions are being checked. + /// An array of granted permission names as strings. public static Task GetGrantedPermissionsAsync( this IResourcePermissionChecker resourcePermissionChecker, TEntity entity @@ -55,7 +77,15 @@ public static class EntityResourcePermissionCheckerExtensions entity.GetKeys().JoinAsString(",") ); } - + + /// + /// Retrieves an array of granted entity IDs for a specific permission. + /// + /// The type of the entity. + /// The type of the entity's primary key. + /// The resource permission checker instance. + /// The name of the permission to check. + /// An array of entity IDs (of type ) for which the permission is granted. public async static Task GetGrantedEntityIdsAsync( this IResourcePermissionChecker resourcePermissionChecker, string permissionName