コード例 #1
0
 public static bool HasRightTo(this ClaimsPrincipal usr, string accessPolicy)
 {
     if (!usr.Identity.IsAuthenticated)
     {
         return(false);
     }
     return(Freshly.CheckAccess(usr.Identity.Name, accessPolicy));
 }
コード例 #2
0
        protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, AccessRuleRequirement requirement)
        {
            bool granted = Freshly.CheckAccess(context.User.Identity.Name, requirement.accessPolicy);

            if (granted)
            {
                context.Succeed(requirement);
            }
            return(Task.CompletedTask);
        }