Table of Contents

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

authorizationService IAuthorizationService

The service that evaluates the policies.

applicationContext IApplicationContext

The 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

policyName string

The name of the policy

exceptionMessage string

The 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

policyName string

The name of the policy.

Returns

Task<bool>

true when there is a principal that satisfies the policy; false when there is no principal or the policy is not satisfied.