public static bool EvaluateRole(Func <string, bool> roleMatcher, Func <string, bool> userMatcher, string rule) { RoleParser parser = new RoleParser(); IAccessRule evaluator = parser.Parse(rule); return(evaluator.Evaluate(roleMatcher, userMatcher)); }
public bool IsAuthorized(AuthorizationContext filterContext, string accessRule, string actionKey, string parentActionKey) { bool?result = null; try { RoleParser parser = new RoleParser(); IAccessRule accessRuleObj = parser.Parse(accessRule); result = accessRuleObj.Evaluate( role => filterContext.HttpContext.User.IsInRole(role) , userName => filterContext.HttpContext.User.Identity.Name.ToLowerInvariant() == userName.ToLowerInvariant() ); } catch { result = false; } return(result.HasValue? result.Value: false); }
public bool Evaluate(Func <string, bool> roleMatcher, Func <string, bool> userMatcher) { return(InnerRule.Evaluate(roleMatcher, userMatcher)); }