67 lines
4.6 KiB
C#
67 lines
4.6 KiB
C#
using adas_core.Domain.Enums;
|
|
using adas_core.Domain.Models.AppSettings;
|
|
using adas_core.Domain.Models.MongoModels;
|
|
|
|
namespace adas_core.Application.Services.Interfaces;
|
|
|
|
public interface IPermissionService
|
|
{
|
|
/// <summary>
|
|
/// Retrieves the set of display permission types applicable to the specified user for the given display.
|
|
/// </summary>
|
|
/// <param name="display">The display for which permissions are being evaluated.</param>
|
|
/// <param name="user">The user whose permissions for the display are being retrieved.</param>
|
|
/// <returns>A task that represents the asynchronous operation, containing the <see cref="DisplayPermissionTypes"/> granted to the user for the display.</returns>
|
|
public Task<DisplayPermissionTypes> GetPermissionsForDisplay(Display display, User user);
|
|
/// <summary>
|
|
/// Retrieves the display-friendly permission types applicable to the specified user for the given unit.
|
|
/// </summary>
|
|
/// <param name="unitId">The identifier of the unit whose permissions are being queried.</param>
|
|
/// <param name="user">The user whose permissions for the unit should be evaluated.</param>
|
|
/// <returns>A task that represents the asynchronous operation, containing the <see cref="DisplayPermissionTypes"/> for the specified unit and user.</returns>
|
|
public Task<DisplayPermissionTypes> GetPermissionsForUnit(string unitId, User user);
|
|
/// <summary>
|
|
/// Retrieves the panel permission types associated with the specified user.
|
|
/// </summary>
|
|
/// <param name="user">The user whose panel permissions are being queried.</param>
|
|
/// <returns>The <see cref="PanelPermissionTypes"/> granted to the specified user.</returns>
|
|
public PanelPermissionTypes GetPermissionsForPanel(User user);
|
|
/// <summary>
|
|
/// Retrieves the panel permission types associated with the specified user.
|
|
/// </summary>
|
|
/// <param name="user">The identifier or name of the user whose panel permissions are being requested.</param>
|
|
/// <returns>A task that represents the asynchronous operation, containing the <see cref="PanelPermissionTypes"/> granted to the user.</returns>
|
|
public Task<PanelPermissionTypes> GetPermissionsForPanel(string user);
|
|
|
|
/// <summary>
|
|
/// Asynchronously checks whether the specified user, with the given role and source permission, has access to the specified display.
|
|
/// </summary>
|
|
/// <param name="username">The name of the user whose access is being verified.</param>
|
|
/// <param name="role">The role assigned to the user, used to determine access rights.</param>
|
|
/// <param name="source">The source permission type considered when evaluating access.</param>
|
|
/// <param name="displayId">The identifier of the display for which access is being checked.</param>
|
|
/// <returns>A task that represents the asynchronous operation. The task result is <c>true</c> if the user has access to the display; otherwise, <c>false</c>.</returns>
|
|
Task<bool> HasAccessToDisplay(string username, PermissionEnum.RolesType role,
|
|
PermissionEnum.SourcePermissionsEnum source, string displayId);
|
|
|
|
/// <summary>
|
|
/// Asynchronously determines whether the specified user, with the given role and permission source, has access to the identified unit.
|
|
/// </summary>
|
|
/// <param name="username">The identifier of the user whose access is being evaluated.</param>
|
|
/// <param name="role">The role assigned to the user, used in the access evaluation.</param>
|
|
/// <param name="source">The permission source used to resolve the user's access rights.</param>
|
|
/// <param name="unitId">The identifier of the unit to check access against.</param>
|
|
/// <returns>A task that resolves to <c>true</c> if the user has access to the specified unit; otherwise, <c>false</c>.</returns>
|
|
Task<bool> HasAccessToUnit(string username, PermissionEnum.RolesType role,
|
|
PermissionEnum.SourcePermissionsEnum source, string unitId);
|
|
|
|
/// <summary>
|
|
/// Asynchronously determines whether the specified user has access to a panel based on their role and the requested source permission.
|
|
/// </summary>
|
|
/// <param name="username">The identifier of the user whose panel access is being evaluated.</param>
|
|
/// <param name="role">The role assigned to the user, used to resolve applicable permissions.</param>
|
|
/// <param name="source">The source permission being checked against the user's access rights.</param>
|
|
/// <returns>A task that resolves to <c>true</c> if the user has access to the panel; otherwise, <c>false</c>.</returns>
|
|
Task<bool> HasAccessToPanel(string username, PermissionEnum.RolesType role,
|
|
PermissionEnum.SourcePermissionsEnum source);
|
|
} |