Class PermissionAuthorizeAttribute
- Namespace
- adas_core.Authentication.Attributes
- Assembly
- adas-core.Authentication.dll
public class PermissionAuthorizeAttribute : AuthorizeAttribute, IAuthorizeData, IAsyncAuthorizationFilter, IFilterMetadata
- Inheritance
-
PermissionAuthorizeAttribute
- Implements
- Inherited Members
- Extension Methods
Constructors
PermissionAuthorizeAttribute(string, string?)
public PermissionAuthorizeAttribute(string source, string? resourceIdHeader = null)
Parameters
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
contextAuthorizationFilterContextThe AuthorizationFilterContext for the current authorization request, providing access to the HTTP context, services, and the result to set when authorization fails.
Returns
Exceptions
- ForbbidenException
Thrown when the IPermissionService cannot be resolved from the request services.