| File: IAuthorizationService.cs | Web Access |
| Project: src\aspnetcore\src\Security\Authorization\Core\src\Microsoft.AspNetCore.Authorization.csproj (Microsoft.AspNetCore.Authorization) |
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.Security.Claims; using System.Threading.Tasks; namespace Microsoft.AspNetCore.Authorization; /// <summary> /// Checks policy based permissions for a user /// </summary> public interface IAuthorizationService { /// <summary> /// Checks if a user meets a specific set of requirements for the specified resource /// </summary> /// <param name="user">The user to evaluate the requirements against.</param> /// <param name="resource"> /// 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. /// </param> /// <param name="requirements">The requirements to evaluate.</param> /// <returns> /// A <see cref="Task{TResult}"/> that contains an <see cref="AuthorizationResult"/> indicating whether authorization has succeeded. /// The result's <see cref="AuthorizationResult.Succeeded"/> property is <c>true</c> when the user fulfills the policy; otherwise <c>false</c>. /// </returns> /// <remarks> /// Resource is an optional parameter and may be null. Please ensure that you check it is not /// null before acting upon it. /// </remarks> Task<AuthorizationResult> AuthorizeAsync(ClaimsPrincipal user, object? resource, IEnumerable<IAuthorizationRequirement> requirements); /// <summary> /// Checks if a user meets a specific authorization policy /// </summary> /// <param name="user">The user to check the policy against.</param> /// <param name="resource"> /// 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. /// </param> /// <param name="policyName">The name of the policy to check against a specific context.</param> /// <returns> /// A <see cref="Task{TResult}"/> that contains an <see cref="AuthorizationResult"/> indicating whether authorization has succeeded. /// The result's <see cref="AuthorizationResult.Succeeded"/> property is <c>true</c> when the policy has been fulfilled; otherwise <c>false</c>. /// </returns> /// <remarks> /// Resource is an optional parameter and may be null. Please ensure that you check it is not /// null before acting upon it. /// </remarks> Task<AuthorizationResult> AuthorizeAsync(ClaimsPrincipal user, object? resource, string policyName); }