DefaultAuthorizationService Class¶
The default implementation of an Microsoft.AspNetCore.Authorization.IAuthorizationService
.
- Namespace
Microsoft.AspNetCore.Authorization
- Assemblies
- Microsoft.AspNetCore.Authorization
Syntax¶
public class DefaultAuthorizationService : IAuthorizationService
-
class
Microsoft.AspNetCore.Authorization.
DefaultAuthorizationService
Constructors¶
-
DefaultAuthorizationService
(Microsoft.AspNetCore.Authorization.IAuthorizationPolicyProvider, System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Authorization.IAuthorizationHandler>, Microsoft.Extensions.Logging.ILogger<Microsoft.AspNetCore.Authorization.DefaultAuthorizationService>)¶ Creates a new instance of
Microsoft.AspNetCore.Authorization.DefaultAuthorizationService
.Arguments: - policyProvider (Microsoft.AspNetCore.Authorization.IAuthorizationPolicyProvider) – The
Microsoft.AspNetCore.Authorization.IAuthorizationPolicyProvider
used to provide policies. - handlers (System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Authorization.IAuthorizationHandler>) – The handlers used to fulfill
Microsoft.AspNetCore.Authorization.IAuthorizationRequirement
s. - logger (Microsoft.Extensions.Logging.ILogger<Microsoft.AspNetCore.Authorization.DefaultAuthorizationService>) – The logger used to log messages, warnings and errors.
public DefaultAuthorizationService(IAuthorizationPolicyProvider policyProvider, IEnumerable<IAuthorizationHandler> handlers, ILogger<DefaultAuthorizationService> logger)
- policyProvider (Microsoft.AspNetCore.Authorization.IAuthorizationPolicyProvider) – The
-
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) – The resource to evaluate the requirements against.
- 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 succeded. This value is <returns>true</returns> when the user fulfills the policy otherwise <returns>false</returns>.
public 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) – The resource the policy should be checked with.
- 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 succeded. This value is <returns>true</returns> when the user fulfills the policy otherwise <returns>false</returns>.
public Task<bool> AuthorizeAsync(ClaimsPrincipal user, object resource, string policyName)
-