Class ApplicationAuthorizationPolicy
- Namespace
- Arc4u.Authorization
- Assembly
- Arc4u.Authorization.dll
Default IApplicationAuthorizationPolicy: evaluates the policy with the IAuthorizationService for the principal of the current IApplicationContext.
[Export(typeof(IApplicationAuthorizationPolicy))]
[Scoped]
public class ApplicationAuthorizationPolicy : IApplicationAuthorizationPolicy
- Inheritance
-
ApplicationAuthorizationPolicy
- Implements
- Inherited Members
Constructors
ApplicationAuthorizationPolicy(IAuthorizationService, IApplicationContext)
Initializes a new instance of the ApplicationAuthorizationPolicy class.
public ApplicationAuthorizationPolicy(IAuthorizationService authorizationService, IApplicationContext applicationContext)
Parameters
authorizationServiceIAuthorizationServiceThe service that evaluates the policies.
applicationContextIApplicationContextThe application context giving the current principal.
Methods
AuthorizeAsync(string, string?)
Check if the user is authorized to access the resource based on the policy name.
public Task AuthorizeAsync(string policyName, string? exceptionMessage = null)
Parameters
policyNamestringThe name of the policy
exceptionMessagestringThe message of the exception thrown when the user is not authorized. When empty, a default message giving the policy name is used.
Returns
- Task
A task that completes when the user is authorized.
Exceptions
- UnauthorizedAccessException
If the user is not authorized.
IsAuthorizeAsync(string)
Checks whether the current principal satisfies the policy.
public Task<bool> IsAuthorizeAsync(string policyName)
Parameters
policyNamestringThe name of the policy.