Class AspNetAuthorizationAttributeEvaluator

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

Represents an implementation of IAuthorizationAttributeEvaluator that checks for ASP.NET Core's AuthorizeAttribute.

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

Remarks

The ASP.NET Core attribute type is named in full on purpose: in this namespace an unqualified AuthorizeAttribute resolves to Arc's own attribute, not ASP.NET Core's.

Constructors

AspNetAuthorizationAttributeEvaluator()

public AspNetAuthorizationAttributeEvaluator()

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.