Class AuthorizationAttributeEvaluator

Namespace
Cratis.Arc.Authorization
Assembly
Cratis.Arc.Core.dll

Represents an implementation of IAuthorizationAttributeEvaluator that checks for the Cratis Arc AuthorizeAttribute.

public class AuthorizationAttributeEvaluator : IAuthorizationAttributeEvaluator
Inheritance
AuthorizationAttributeEvaluator
Implements
Inherited Members
Extension Methods

Constructors

AuthorizationAttributeEvaluator()

public AuthorizationAttributeEvaluator()

Methods

GetAuthorizationInfo(MethodInfo)

Checks if the method has an authorization attribute and retrieves role information.

public (bool HasAuthorize, string? Roles)? GetAuthorizationInfo(MethodInfo method)

Parameters

method MethodInfo

The method to check.

Returns

(bool HasAuthorize, string Roles)?

Tuple with (hasAuthorize, roles) or null if this evaluator cannot determine.

GetAuthorizationInfo(Type)

Checks if the type has an authorization attribute and retrieves role information.

public (bool HasAuthorize, string? Roles)? GetAuthorizationInfo(Type type)

Parameters

type Type

The type to check.

Returns

(bool HasAuthorize, string Roles)?

Tuple with (hasAuthorize, roles) or null if this evaluator cannot determine.

GetAuthorizationRequirements(MethodInfo)

Gets every authorization requirement declared on the method.

public IEnumerable<AuthorizationRequirement> GetAuthorizationRequirements(MethodInfo method)

Parameters

method MethodInfo

The method to check.

Returns

IEnumerable<AuthorizationRequirement>

One AuthorizationRequirement per authorization attribute, all of which must be satisfied.

Remarks

The default derives a single requirement from GetAuthorizationInfo(MethodInfo). Override it to report every attribute, so that stacked attributes are all enforced rather than only the first one found.

GetAuthorizationRequirements(Type)

Gets every authorization requirement declared on the type.

public IEnumerable<AuthorizationRequirement> GetAuthorizationRequirements(Type type)

Parameters

type Type

The type to check.

Returns

IEnumerable<AuthorizationRequirement>

One AuthorizationRequirement per authorization attribute, all of which must be satisfied.

Remarks

The default derives a single requirement from GetAuthorizationInfo(Type). Override it to report every attribute, so that stacked attributes are all enforced rather than only the first one found.