| | | 1 | | using ArturRios.Util.WebApi.Security.Filters; |
| | | 2 | | using Microsoft.AspNetCore.Mvc; |
| | | 3 | | |
| | | 4 | | namespace ArturRios.Util.WebApi.Security.Attributes; |
| | | 5 | | |
| | | 6 | | /// <summary>Restricts an action or controller to users whose role is one of <see cref="RoleRequirementFilter"/>'s |
| | | 7 | | /// authorized roles, applied declaratively via <see cref="TypeFilterAttribute"/>.</summary> |
| | | 8 | | public class RoleRequirementAttribute : TypeFilterAttribute |
| | | 9 | | { |
| | | 10 | | /// <summary>Initializes the attribute with the roles allowed to access the decorated action or controller.</summary |
| | | 11 | | /// <param name="authorizedRoles">The role values permitted to access the resource.</param> |
| | 0 | 12 | | public RoleRequirementAttribute(params int[] authorizedRoles) : base(typeof(RoleRequirementFilter)) |
| | 0 | 13 | | { |
| | 0 | 14 | | object[] arguments = [authorizedRoles]; |
| | | 15 | | |
| | 0 | 16 | | Arguments = arguments; |
| | 0 | 17 | | } |
| | | 18 | | } |