public static bool HasRightTo(this ClaimsPrincipal usr, string accessPolicy) { if (!usr.Identity.IsAuthenticated) { return(false); } return(Freshly.CheckAccess(usr.Identity.Name, accessPolicy)); }
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); }