=== Summary: 675 files | 7 generated | 484 fresh | 4605 untracked | 4268 adopted | 355 marked | 466 validated-ok | 2+0 stale (sig+body) | 0 skipped | 0 failed | elapsed 11:08:11.442 (40091.44s) ===
This commit is contained in:
@@ -34,6 +34,7 @@ public class PermissionService(
|
||||
/// <param name="user">The user whose authorizations and roles are evaluated to determine the applicable display permissions.</param>
|
||||
/// <returns>A <see cref="Task{DisplayPermissionTypes}"/> containing the display permission configuration corresponding to the matched role.</returns>
|
||||
/// <exception cref="ForbbidenException">Thrown when the user has no authorizations available, or when none of the user's authorities match the given display or its unit.</exception>
|
||||
/// <!-- aidoc:v1 sig=d8506c7 body=38a9690 -->
|
||||
public async Task<DisplayPermissionTypes> GetPermissionsForDisplay(Display display, User user)
|
||||
{
|
||||
var authorities = user.Authorization;
|
||||
@@ -92,6 +93,7 @@ public class PermissionService(
|
||||
/// <param name="user">The user whose authorizations and role are used to determine the permissions for the unit.</param>
|
||||
/// <returns>A <see cref="Task{DisplayPermissionTypes}"/> that resolves to the permission configuration matching the user's role for the specified unit.</returns>
|
||||
/// <exception cref="ForbbidenException">Thrown when the user has no authorizations, or when no authorization entry matches the provided <paramref name="unitId"/>.</exception>
|
||||
/// <!-- aidoc:v1 sig=759c4e6 body=fead12d -->
|
||||
public Task<DisplayPermissionTypes> GetPermissionsForUnit(string unitId, User user)
|
||||
{
|
||||
var authorities = user.Authorization;
|
||||
@@ -165,6 +167,7 @@ public class PermissionService(
|
||||
/// <param name="user">The username of the user whose panel permissions are being requested.</param>
|
||||
/// <returns>The <see cref="PanelPermissionTypes"/> that apply to the user based on their authorities.</returns>
|
||||
/// <exception cref="ForbbidenException">Thrown when no user is found with the specified username.</exception>
|
||||
/// <!-- aidoc:v1 sig=d26061a body=58fe8bf -->
|
||||
public async Task<PanelPermissionTypes> GetPermissionsForPanel(string user)
|
||||
{
|
||||
var userFound = await userRepository.Value.GetByUserName(user);
|
||||
@@ -179,6 +182,7 @@ public class PermissionService(
|
||||
/// <param name="user">The user whose panel permissions are being resolved; must carry authorization data.</param>
|
||||
/// <returns>The <see cref="PanelPermissionTypes"/> associated with the matched role.</returns>
|
||||
/// <exception cref="ForbbidenException">Thrown when the user has no authorities or no authority grants panel access.</exception>
|
||||
/// <!-- aidoc:v1 sig=cd8a599 body=982b53f -->
|
||||
public PanelPermissionTypes GetPermissionsForPanel(User user)
|
||||
{
|
||||
var authorities = user.Authorization;
|
||||
@@ -222,6 +226,7 @@ public class PermissionService(
|
||||
/// <param name="source">The source permission context used when evaluating access to the display.</param>
|
||||
/// <param name="displayId">The string identifier of the display; must be parseable as an ObjectId or access is denied.</param>
|
||||
/// <returns>A task that resolves to true if the user's role and authorities grant access to the specified display; otherwise, false.</returns>
|
||||
/// <!-- aidoc:v1 sig=90064ea body=c31fd83 -->
|
||||
public async Task<bool> HasAccessToDisplay(string username, PermissionEnum.RolesType userRole,
|
||||
PermissionEnum.SourcePermissionsEnum source, string displayId)
|
||||
{
|
||||
@@ -246,6 +251,7 @@ public class PermissionService(
|
||||
/// <param name="source">The source permission context associated with the access evaluation.</param>
|
||||
/// <param name="unitId">The identifier of the unit to check access against.</param>
|
||||
/// <returns>A task that resolves to true if the user has the required access to the unit; otherwise, false.</returns>
|
||||
/// <!-- aidoc:v1 sig=906d082 body=40fc526 -->
|
||||
public async Task<bool> HasAccessToUnit(string username, PermissionEnum.RolesType userRole,
|
||||
PermissionEnum.SourcePermissionsEnum source, string unitId)
|
||||
{
|
||||
@@ -265,6 +271,8 @@ public class PermissionService(
|
||||
/// <param name="userRole">The role required to access the panel.</param>
|
||||
/// <param name="source">The source permission context used for the access check.</param>
|
||||
/// <returns>true if the user exists and has the required role within the panel; otherwise, false.</returns>
|
||||
/// <!-- aidoc-review:v1 severity=high kind=mentions_removed_behavior
|
||||
/// "The 'source' parameter is documented as 'The source permission context used for the access check', but the parameter is never referenced in the method body." -->
|
||||
public async Task<bool> HasAccessToPanel(string username, PermissionEnum.RolesType userRole,
|
||||
PermissionEnum.SourcePermissionsEnum source)
|
||||
{
|
||||
@@ -286,6 +294,7 @@ public class PermissionService(
|
||||
/// <param name="authorities">The list of authorizations to search; a null or empty value causes the method to return <c>false</c>.</param>
|
||||
/// <param name="role">The role to find within the matched authorizations or the display's unit.</param>
|
||||
/// <returns><c>true</c> if the role is found in any matched authorization or in the display's unit; otherwise, <c>false</c>.</returns>
|
||||
/// <!-- aidoc:v1 sig=991ebcc body=1585fe1 -->
|
||||
private static bool SearchRoleInDisplay(Display display, List<Authorization>? authorities,
|
||||
PermissionEnum.RolesType role)
|
||||
{
|
||||
@@ -309,6 +318,7 @@ public class PermissionService(
|
||||
/// <param name="authorities">The list of authorizations to inspect; if <c>null</c>, the method short-circuits and returns <c>false</c>.</param>
|
||||
/// <param name="role">The role type to look for within the authorities of the specified unit.</param>
|
||||
/// <returns><c>true</c> if an authority exists for <paramref name="unitId"/> with a role equal to <paramref name="role"/>; otherwise, <c>false</c>.</returns>
|
||||
/// <!-- aidoc:v1 sig=693c67c body=dfaeeb7 -->
|
||||
private static bool SearchRoleInUnit(string unitId, List<Authorization>? authorities, PermissionEnum.RolesType role)
|
||||
{
|
||||
if (authorities == null)
|
||||
@@ -331,6 +341,8 @@ public class PermissionService(
|
||||
/// <param name="role">The role to look for within the panel-authorized entries.</param>
|
||||
/// <returns><c>true</c> if at least one entry has <c>PanelAuthorization</c> enabled and matches the specified role; otherwise, <c>false</c>.</returns>
|
||||
/// <exception cref="ArgumentException">Thrown when an entry's <c>Rol</c> value cannot be parsed into a valid <see cref="PermissionEnum.RolesType"/>.</exception>
|
||||
/// <!-- aidoc-review:v1 severity=high kind=wrong_summary
|
||||
/// "The summary states the method 'Returns false... when an entry has no role mapping', but when auth.Rol is null, the code calls Enum.Parse with string.Empty, which throws ArgumentException rather than returning false." -->
|
||||
private static bool SearchRoleInPanel(List<Authorization>? authorities, PermissionEnum.RolesType role)
|
||||
{
|
||||
if (authorities == null)
|
||||
|
||||
Reference in New Issue
Block a user