// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Collections.Generic; using System.Security.Claims; using System.Threading.Tasks; namespace Microsoft.AspNetCore.Authorization { /// /// Checks policy based permissions for a user /// public interface IAuthorizationService { /// /// Checks if a user meets a specific set of requirements for the specified resource /// /// The user to evaluate the requirements against. /// /// 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. /// /// The requirements to evaluate. /// /// A flag indicating whether authorization has succeeded. /// This value is true when the user fulfills the policy; otherwise false. /// /// /// Resource is an optional parameter and may be null. Please ensure that you check it is not /// null before acting upon it. /// Task AuthorizeAsync(ClaimsPrincipal user, object resource, IEnumerable requirements); /// /// Checks if a user meets a specific authorization policy /// /// The user to check the policy against. /// /// 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. /// /// The name of the policy to check against a specific context. /// /// A flag indicating whether authorization has succeeded. /// Returns a flag indicating whether the user, and optional resource has fulfilled the policy. /// true when the the policy has been fulfilled; otherwise false. /// /// /// Resource is an optional parameter and may be null. Please ensure that you check it is not /// null before acting upon it. /// Task AuthorizeAsync(ClaimsPrincipal user, object resource, string policyName); } }