Browse Source

Added summaries

pull/24374/head
Halil İbrahim Kalkan 11 months ago
parent
commit
87e41a6166
  1. 35
      framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/Resources/IResourcePermissionChecker.cs
  2. 39
      framework/src/Volo.Abp.Authorization.Abstractions/Volo/Abp/Authorization/Permissions/Resources/ResourcePermissionCheckerExtensions.cs
  3. 36
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Authorization/Permissions/Resources/EntityResourcePermissionCheckerExtensions.cs

35
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
{
/// <summary>
/// Checks if the given permission is granted for the given resource.
/// </summary>
/// <param name="permissionName">The name of the permission.</param>
/// <param name="resourceName">The name of the resource.</param>
/// <param name="resourceKey">Resource key</param>
/// <returns>
/// True if the permission is granted.
/// </returns>
Task<bool> IsGrantedAsync(
string permissionName,
string resourceName,
string resourceKey
);
/// <summary>
/// Gets all permissions for the given resource.
/// </summary>
/// <param name="resourceName">Resource name</param>
/// <param name="resourceKey">Resource key</param>
/// <returns>
/// A dictionary of permission names and their states.
/// </returns>
Task<IDictionary<string, bool>> GetPermissionsAsync(
string resourceName,
string resourceKey
);
/// <summary>
/// Gets all granted permissions for the given resource.
/// </summary>
/// <param name="resourceName">Resource name</param>
/// <param name="resourceKey">Resource key</param>
/// <returns>
/// An array of granted permission names.
/// </returns>
Task<string[]> GetGrantedPermissionsAsync(
string resourceName,
string resourceKey
);
/// <summary>
/// Retrieves the keys of resources for which the specified permission is granted.
/// </summary>
/// <param name="resourceName">The name of the resource.</param>
/// <param name="permissionName">The name of the permission.</param>
/// <returns>
/// An array of resource keys where the specified permission is granted.
/// </returns>
Task<string[]> GetGrantedResourceKeysAsync(
string resourceName,
string permissionName

39
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
{
/// <summary>
/// Checks if a specific permission is granted for a resource with a given key.
/// </summary>
/// <typeparam name="TResource">The type of the resource.</typeparam>
/// <param name="resourcePermissionChecker">The resource permission checker instance.</param>
/// <param name="permissionName">The name of the permission to check.</param>
/// <param name="resource">The resource instance to check permission for.</param>
/// <param name="resourceKey">The unique key identifying the resource instance.</param>
/// <returns>A task that represents the asynchronous operation. The task result contains a boolean value indicating whether the permission is granted.</returns>
public static Task<bool> IsGrantedAsync<TResource>(
this IResourcePermissionChecker resourcePermissionChecker,
string permissionName,
@ -23,7 +32,15 @@ public static class ResourcePermissionCheckerExtensions
resourceKey.ToString()!
);
}
/// <summary>
/// Retrieves a dictionary of permissions and their granted statuses for a specific resource.
/// </summary>
/// <typeparam name="TResource">The type of the resource.</typeparam>
/// <param name="resourcePermissionChecker">The resource permission checker instance.</param>
/// <param name="resource">The resource instance for which permissions are being checked.</param>
/// <param name="resourceKey">The unique key identifying the resource instance.</param>
/// <returns>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.</returns>
public static Task<IDictionary<string, bool>> GetPermissionsAsync<TResource>(
this IResourcePermissionChecker resourcePermissionChecker,
TResource resource,
@ -39,7 +56,15 @@ public static class ResourcePermissionCheckerExtensions
resourceKey.ToString()!
);
}
/// <summary>
/// Retrieves the list of granted permissions for a specific resource with a given key.
/// </summary>
/// <typeparam name="TResource">The type of the resource.</typeparam>
/// <param name="resourcePermissionChecker">The resource permission checker instance.</param>
/// <param name="resource">The resource instance to retrieve permissions for.</param>
/// <param name="resourceKey">The unique key identifying the resource instance.</param>
/// <returns>A task that represents the asynchronous operation. The task result contains an array of strings representing the granted permissions.</returns>
public static Task<string[]> GetGrantedPermissionsAsync<TResource>(
this IResourcePermissionChecker resourcePermissionChecker,
TResource resource,
@ -55,7 +80,15 @@ public static class ResourcePermissionCheckerExtensions
resourceKey.ToString()!
);
}
/// <summary>
/// Retrieves the keys of the resources granted a specific permission.
/// </summary>
/// <typeparam name="TResource">The type of the resource.</typeparam>
/// <param name="resourcePermissionChecker">The resource permission checker instance.</param>
/// <param name="resource">The resource instance to check granted permissions for.</param>
/// <param name="permissionName">The name of the permission to check.</param>
/// <returns>A task that represents the asynchronous operation. The task result contains an array of strings representing the granted resource keys.</returns>
public static Task<string[]> GetGrantedResourceKeysAsync<TResource>(
this IResourcePermissionChecker resourcePermissionChecker,
TResource resource,

36
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
{
/// <summary>
/// Checks if the specified permission is granted for the given entity.
/// </summary>
/// <typeparam name="TEntity">The type of the entity.</typeparam>
/// <param name="resourcePermissionChecker">The resource permission checker instance.</param>
/// <param name="permissionName">The name of the permission to check.</param>
/// <param name="entity">The entity for which the permission is being checked.</param>
/// <returns>A task that represents the asynchronous operation. The task result is a boolean indicating whether the permission is granted.</returns>
public static Task<bool> IsGrantedAsync<TEntity>(
this IResourcePermissionChecker resourcePermissionChecker,
string permissionName,
@ -25,7 +33,14 @@ public static class EntityResourcePermissionCheckerExtensions
entity.GetKeys().JoinAsString(",")
);
}
/// <summary>
/// Retrieves a dictionary of permissions and their granted status for the specified entity.
/// </summary>
/// <typeparam name="TEntity">The type of the entity.</typeparam>
/// <param name="resourcePermissionChecker">The resource permission checker instance.</param>
/// <param name="entity">The entity for which the permissions are being retrieved.</param>
/// <returns>A dictionary where the keys are permission names and the values are booleans indicating whether the permission is granted.</returns>
public static Task<IDictionary<string, bool>> GetPermissionsAsync<TEntity>(
this IResourcePermissionChecker resourcePermissionChecker,
TEntity entity
@ -40,7 +55,14 @@ public static class EntityResourcePermissionCheckerExtensions
entity.GetKeys().JoinAsString(",")
);
}
/// <summary>
/// Retrieves an array of granted permissions for a specific entity.
/// </summary>
/// <typeparam name="TEntity">The type of the entity.</typeparam>
/// <param name="resourcePermissionChecker">The resource permission checker instance.</param>
/// <param name="entity">The entity for which the permissions are being checked.</param>
/// <returns>An array of granted permission names as strings.</returns>
public static Task<string[]> GetGrantedPermissionsAsync<TEntity>(
this IResourcePermissionChecker resourcePermissionChecker,
TEntity entity
@ -55,7 +77,15 @@ public static class EntityResourcePermissionCheckerExtensions
entity.GetKeys().JoinAsString(",")
);
}
/// <summary>
/// Retrieves an array of granted entity IDs for a specific permission.
/// </summary>
/// <typeparam name="TEntity">The type of the entity.</typeparam>
/// <typeparam name="TKey">The type of the entity's primary key.</typeparam>
/// <param name="resourcePermissionChecker">The resource permission checker instance.</param>
/// <param name="permissionName">The name of the permission to check.</param>
/// <returns>An array of entity IDs (of type <typeparamref name="TKey"/>) for which the permission is granted.</returns>
public async static Task<TKey[]> GetGrantedEntityIdsAsync<TEntity, TKey>(
this IResourcePermissionChecker resourcePermissionChecker,
string permissionName

Loading…
Cancel
Save