mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 15:11:10 +00:00
Implements authorization caching and check in the web client
This commit is contained in:
1 parent
7bca5b1ba3
commit
8eb1b9f13c
108 files changed
+5931
-73
No files matched your search
+15
-4
@@ -1,5 +1,8 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Authorization;
|
||||
using Lumina.Application.Common.Infrastructure.Authorization.Policies.Common.Base;
|
||||
using Lumina.Domain.Common.Enums.Authorization;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@@ -16,19 +19,19 @@ public interface IAuthorizationService
|
||||
/// Determines whether the specified user has a specific permission.
|
||||
/// </summary>
|
||||
/// <param name="userId">The Id of the user for whom to check the permission.</param>
|
||||
/// <param name="permission">The name of the permission to check.</param>
|
||||
/// <param name="permission">The permission to check.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns><see langword="true"/> if the user has the specified permission, <see langword="false"/> otherwise.</returns>
|
||||
Task<bool> HasPermissionAsync(Guid userId, string permission, CancellationToken cancellationToken);
|
||||
Task<bool> HasPermissionAsync(Guid userId, AuthorizationPermission permission, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified user belongs to a specific role.
|
||||
/// </summary>
|
||||
/// <param name="userId">The Id of the user for whom to check the role.</param>
|
||||
/// <param name="role">The name of the role to check.</param>
|
||||
/// <param name="role">The role to check.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns><see langword="true"/> if the user is in the specified role, <see langword="false"/> otherwise.</returns>
|
||||
Task<bool> IsInRoleAsync(Guid userId, string role, CancellationToken cancellationToken);
|
||||
Task<bool> IsInRoleAsync(Guid userId, AuthorizationRole role, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Evaluates whether the specified user meets the conditions defined in the specified authorization policy.
|
||||
@@ -38,4 +41,12 @@ public interface IAuthorizationService
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns><see langword="true"/> if the user satisfies the policy, <see langword="false"/> otherwise.</returns>
|
||||
Task<bool> EvaluatePolicyAsync<TAuthorizationPolicy>(Guid userId, CancellationToken cancellationToken) where TAuthorizationPolicy : IAuthorizationPolicy;
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all authorization roles and permissions of a user identified by <paramref name="userId"/>.
|
||||
/// </summary>
|
||||
/// <param name="userId">The id of the user for whom to retrieve the authorization roles and permissions.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>An <see cref="ErrorOr{TValue}"/> containing either a <see cref="UserAuthorizationEntity"/>, or an error.</returns>
|
||||
Task<ErrorOr<UserAuthorizationEntity>> GetUserAuthorizationAsync(Guid userId, CancellationToken cancellationToken);
|
||||
}
|
||||
Reference in new issue
Block a user