Example #1
0
        public bool IsGranted(AuthRole role, string resource)
        {
            Ensure.ArgumentNotEmpty(role, nameof(role));
            Ensure.ArgumentNotEmpty(resource, nameof(resource));

            return(role.Permissoins.ContainsKey(resource) ? true : false);
        }
Example #2
0
        public bool IsGranted(AuthRole role, string resource, string action)
        {
            Ensure.ArgumentNotEmpty(role, nameof(role));
            Ensure.ArgumentNotEmpty(resource, nameof(resource));
            Ensure.ArgumentNotEmpty(action, nameof(action));

            if (role.Permissoins.TryGetValue(resource, out ICollection <string> actions))
            {
                if (actions == null || actions.Contains(action))
                {
                    return(true);
                }
            }

            return(false);
        }
Example #3
0
        public void SaveRole(AuthRole role)
        {
            Ensure.ArgumentNotEmpty(role, nameof(role));

            _repo.UpsertRole(role);
        }