Share via


IAuthorizationService.AuthorizeAsync Method

Definition

Overloads

AuthorizeAsync(ClaimsPrincipal, Object, IEnumerable<IAuthorizationRequirement>)

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

AuthorizeAsync(ClaimsPrincipal, Object, String)

Checks if a user meets a specific authorization policy

AuthorizeAsync(ClaimsPrincipal, Object, IEnumerable<IAuthorizationRequirement>)

Source:
IAuthorizationService.cs
Source:
IAuthorizationService.cs
Source:
IAuthorizationService.cs
Source:
IAuthorizationService.cs

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

public:
 System::Threading::Tasks::Task<bool> ^ AuthorizeAsync(System::Security::Claims::ClaimsPrincipal ^ user, System::Object ^ resource, System::Collections::Generic::IEnumerable<Microsoft::AspNetCore::Authorization::IAuthorizationRequirement ^> ^ requirements);
public:
 System::Threading::Tasks::Task<Microsoft::AspNetCore::Authorization::AuthorizationResult ^> ^ AuthorizeAsync(System::Security::Claims::ClaimsPrincipal ^ user, System::Object ^ resource, System::Collections::Generic::IEnumerable<Microsoft::AspNetCore::Authorization::IAuthorizationRequirement ^> ^ requirements);
public System.Threading.Tasks.Task<bool> AuthorizeAsync (System.Security.Claims.ClaimsPrincipal user, object resource, System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Authorization.IAuthorizationRequirement> requirements);
public System.Threading.Tasks.Task<Microsoft.AspNetCore.Authorization.AuthorizationResult> AuthorizeAsync (System.Security.Claims.ClaimsPrincipal user, object resource, System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Authorization.IAuthorizationRequirement> requirements);
public System.Threading.Tasks.Task<Microsoft.AspNetCore.Authorization.AuthorizationResult> AuthorizeAsync (System.Security.Claims.ClaimsPrincipal user, object? resource, System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Authorization.IAuthorizationRequirement> requirements);
abstract member AuthorizeAsync : System.Security.Claims.ClaimsPrincipal * obj * seq<Microsoft.AspNetCore.Authorization.IAuthorizationRequirement> -> System.Threading.Tasks.Task<bool>
abstract member AuthorizeAsync : System.Security.Claims.ClaimsPrincipal * obj * seq<Microsoft.AspNetCore.Authorization.IAuthorizationRequirement> -> System.Threading.Tasks.Task<Microsoft.AspNetCore.Authorization.AuthorizationResult>
Public Function AuthorizeAsync (user As ClaimsPrincipal, resource As Object, requirements As IEnumerable(Of IAuthorizationRequirement)) As Task(Of Boolean)
Public Function AuthorizeAsync (user As ClaimsPrincipal, resource As Object, requirements As IEnumerable(Of IAuthorizationRequirement)) As Task(Of AuthorizationResult)

Parameters

user
ClaimsPrincipal

The user to evaluate the requirements against.

resource
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
IEnumerable<IAuthorizationRequirement>

The requirements to evaluate.

Returns

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

Remarks

Resource is an optional parameter and may be null. Please ensure that you check it is not null before acting upon it.

Applies to

AuthorizeAsync(ClaimsPrincipal, Object, String)

Source:
IAuthorizationService.cs
Source:
IAuthorizationService.cs
Source:
IAuthorizationService.cs
Source:
IAuthorizationService.cs

Checks if a user meets a specific authorization policy

public:
 System::Threading::Tasks::Task<bool> ^ AuthorizeAsync(System::Security::Claims::ClaimsPrincipal ^ user, System::Object ^ resource, System::String ^ policyName);
public:
 System::Threading::Tasks::Task<Microsoft::AspNetCore::Authorization::AuthorizationResult ^> ^ AuthorizeAsync(System::Security::Claims::ClaimsPrincipal ^ user, System::Object ^ resource, System::String ^ policyName);
public System.Threading.Tasks.Task<bool> AuthorizeAsync (System.Security.Claims.ClaimsPrincipal user, object resource, string policyName);
public System.Threading.Tasks.Task<Microsoft.AspNetCore.Authorization.AuthorizationResult> AuthorizeAsync (System.Security.Claims.ClaimsPrincipal user, object resource, string policyName);
public System.Threading.Tasks.Task<Microsoft.AspNetCore.Authorization.AuthorizationResult> AuthorizeAsync (System.Security.Claims.ClaimsPrincipal user, object? resource, string policyName);
abstract member AuthorizeAsync : System.Security.Claims.ClaimsPrincipal * obj * string -> System.Threading.Tasks.Task<bool>
abstract member AuthorizeAsync : System.Security.Claims.ClaimsPrincipal * obj * string -> System.Threading.Tasks.Task<Microsoft.AspNetCore.Authorization.AuthorizationResult>
Public Function AuthorizeAsync (user As ClaimsPrincipal, resource As Object, policyName As String) As Task(Of Boolean)
Public Function AuthorizeAsync (user As ClaimsPrincipal, resource As Object, policyName As String) As Task(Of AuthorizationResult)

Parameters

user
ClaimsPrincipal

The user to check the policy against.

resource
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
String

The name of the policy to check against a specific context.

Returns

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

Remarks

Resource is an optional parameter and may be null. Please ensure that you check it is not null before acting upon it.

Applies to