public static bool Check(Dictionary <string, object> claims, string role, string ipAddress) { if (claims == null) { return(false); } if (role != null) { Scopes.Role roleDesc = Scopes.IsRole(role); if (roleDesc == null) { throw new ArgumentException("Invalid Role", "role"); } string scope = null; if (claims.ContainsKey("scope")) { if (claims["scope"] != null) { scope = claims["scope"].ToString(); } } if (string.IsNullOrWhiteSpace(scope) || scope.IndexOf(role) < 0 || scope.IndexOf("disabled") >= 0) { return(false); } } #if Firewall if (ipAddress != null) { if (roleDesc.firewall) { if (!Firewall.is_IPAddressWhiteListed(ipAddress)) { return(false); } } } #endif return(true); }