IAuthorizationService Interface

Checks policy based permissions for a user

Namespace
Microsoft.AspNetCore.Authorization
Assemblies
  • Microsoft.AspNetCore.Authorization

Syntax

public interface IAuthorizationService
interface Microsoft.AspNetCore.Authorization.IAuthorizationService

Methods

AuthorizeAsync(System.Security.Claims.ClaimsPrincipal, System.Object, System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Authorization.IAuthorizationRequirement>)

Checks if a user meets a specific set of requirements for the specified resource

Arguments:
  • user (System.Security.Claims.ClaimsPrincipal) – The user to evaluate the requirements against.
  • resource (System.Object) – An optional resource the policy should be checked with. If a resource is not required for policy evaluation you may pass null as the value.
  • requirements (System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Authorization.IAuthorizationRequirement>) – The requirements to evaluate.
Return type:

System.Threading.Tasks.Task<System.Boolean>

Returns:

A flag indicating whether authorization has succeeded. This value is <returns>true</returns> when the user fulfills the policy; otherwise <returns>false</returns>.

Task<bool> AuthorizeAsync(ClaimsPrincipal user, object resource, IEnumerable<IAuthorizationRequirement> requirements)
AuthorizeAsync(System.Security.Claims.ClaimsPrincipal, System.Object, System.String)

Checks if a user meets a specific authorization policy

Arguments:
  • user (System.Security.Claims.ClaimsPrincipal) – The user to check the policy against.
  • resource (System.Object) – An optional resource the policy should be checked with. If a resource is not required for policy evaluation you may pass null as the value.
  • policyName (System.String) – The name of the policy to check against a specific context.
Return type:

System.Threading.Tasks.Task<System.Boolean>

Returns:

A flag indicating whether authorization has succeeded. Returns a flag indicating whether the user, and optional resource has fulfilled the policy. <returns>true</returns> when the the policy has been fulfilled; otherwise <returns>false</returns>.

Task<bool> AuthorizeAsync(ClaimsPrincipal user, object resource, string policyName)