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

C#
public System.Threading.Tasks.Task<bool> AuthorizeAsync (System.Security.Claims.ClaimsPrincipal user, object resource, System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Authorization.IAuthorizationRequirement> requirements);
C#
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);
C#
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);

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

ASP.NET Core 9.0 ja muut versiot
Tuote Versiot
ASP.NET Core 1.0, 1.1, 2.0, 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0

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

C#
public System.Threading.Tasks.Task<bool> AuthorizeAsync (System.Security.Claims.ClaimsPrincipal user, object resource, string policyName);
C#
public System.Threading.Tasks.Task<Microsoft.AspNetCore.Authorization.AuthorizationResult> AuthorizeAsync (System.Security.Claims.ClaimsPrincipal user, object resource, string policyName);
C#
public System.Threading.Tasks.Task<Microsoft.AspNetCore.Authorization.AuthorizationResult> AuthorizeAsync (System.Security.Claims.ClaimsPrincipal user, object? resource, string policyName);

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

ASP.NET Core 9.0 ja muut versiot
Tuote Versiot
ASP.NET Core 1.0, 1.1, 2.0, 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0