# Class PermissionAuthorizeAttribute

Namespace
  adas_core.Authentication.Attributes

Assembly
  adas-core.Authentication.dll

    public class PermissionAuthorizeAttribute : AuthorizeAttribute, IAuthorizeData, IAsyncAuthorizationFilter, IFilterMetadata

Inheritance
  object
  Attribute
  AuthorizeAttribute
  PermissionAuthorizeAttribute

Implements
  IAuthorizeData
  IAsyncAuthorizationFilter
  IFilterMetadata

Inherited Members
  AuthorizeAttribute.ToString()
  AuthorizeAttribute.Policy
  AuthorizeAttribute.Roles
  AuthorizeAttribute.AuthenticationSchemes
  Attribute.Equals(object)
  Attribute.GetCustomAttribute(Assembly, Type)
  Attribute.GetCustomAttribute(Assembly, Type, bool)
  Attribute.GetCustomAttribute(MemberInfo, Type)
  Attribute.GetCustomAttribute(MemberInfo, Type, bool)
  Attribute.GetCustomAttribute(Module, Type)
  Attribute.GetCustomAttribute(Module, Type, bool)
  Attribute.GetCustomAttribute(ParameterInfo, Type)
  Attribute.GetCustomAttribute(ParameterInfo, Type, bool)
  Attribute.GetCustomAttributes(Assembly)
  Attribute.GetCustomAttributes(Assembly, bool)
  Attribute.GetCustomAttributes(Assembly, Type)
  Attribute.GetCustomAttributes(Assembly, Type, bool)
  Attribute.GetCustomAttributes(MemberInfo)
  Attribute.GetCustomAttributes(MemberInfo, bool)
  Attribute.GetCustomAttributes(MemberInfo, Type)
  Attribute.GetCustomAttributes(MemberInfo, Type, bool)
  Attribute.GetCustomAttributes(Module)
  Attribute.GetCustomAttributes(Module, bool)
  Attribute.GetCustomAttributes(Module, Type)
  Attribute.GetCustomAttributes(Module, Type, bool)
  Attribute.GetCustomAttributes(ParameterInfo)
  Attribute.GetCustomAttributes(ParameterInfo, bool)
  Attribute.GetCustomAttributes(ParameterInfo, Type)
  Attribute.GetCustomAttributes(ParameterInfo, Type, bool)
  Attribute.GetHashCode()
  Attribute.IsDefaultAttribute()
  Attribute.IsDefined(Assembly, Type)
  Attribute.IsDefined(Assembly, Type, bool)
  Attribute.IsDefined(MemberInfo, Type)
  Attribute.IsDefined(MemberInfo, Type, bool)
  Attribute.IsDefined(Module, Type)
  Attribute.IsDefined(Module, Type, bool)
  Attribute.IsDefined(ParameterInfo, Type)
  Attribute.IsDefined(ParameterInfo, Type, bool)
  Attribute.Match(object)
  Attribute.TypeId
  object.Equals(object, object)
  object.GetType()
  object.MemberwiseClone()
  object.ReferenceEquals(object, object)

Extension Methods
  NumberUtils.IsNumber(object)
  NumberUtils.ToDouble(object)
  ObjectUtils.ToStr(object?)

## Constructors

### PermissionAuthorizeAttribute(string, string?)

    public PermissionAuthorizeAttribute(string source, string? resourceIdHeader = null)

#### Parameters

`source` string
`resourceIdHeader` string

## Methods

### OnAuthorizationAsync(AuthorizationFilterContext)

Performs asynchronous authorization by validating the user's roles, username, and source header against the permission service. For the `Panel` source, it verifies that at least one of the user's roles grants access to the panel; for other sources, it requires a resource identifier header (such as `DisplayId` or `UnitId`) and checks access to the corresponding resource. If any required value is missing or no role grants the needed permission, the response is set to ForbidResult.

    public Task OnAuthorizationAsync(AuthorizationFilterContext context)

#### Parameters

`context` AuthorizationFilterContext

  The AuthorizationFilterContext for the current authorization request, providing access to the HTTP context, services, and the result to set when authorization fails.

#### Returns

Task

#### Exceptions

ForbbidenException

  Thrown when the IPermissionService cannot be resolved from the request services.