Beispiel #1
0
        public AuthorizationService(IAuthorizationInitializer[] authorizationInitializers)
        {
            _rootLocation = new AuthorizationLocation();
            AuthorizationRule allowRule = new AuthorizationRule { Action = AuthorizationRuleAction.Allow };
            allowRule.Users.Add("*");
            _rootLocation.Rules.Add(allowRule);

            foreach (IAuthorizationInitializer initializer in authorizationInitializers)
                initializer.Initialize(this);
        }
Beispiel #2
0
        public void AddRule(string locationPath, IList<string> allowUsers, IList<string> allowRoles, IList<string> denyUsers, IList<string> denyRoles)
        {
            AuthorizationLocation location = new AuthorizationLocation { Path = locationPath };

            AuthorizationRule allowRule = new AuthorizationRule { Action = AuthorizationRuleAction.Allow };
            if (allowUsers != null)
                allowRule.Users.AddRange(allowUsers);
            if (allowRoles != null)
                allowRule.Roles.AddRange(allowRoles);
            location.Rules.Add(allowRule);

            AuthorizationRule denyRule = new AuthorizationRule { Action = AuthorizationRuleAction.Deny };
            if (denyUsers != null)
                denyRule.Users.AddRange(denyUsers);
            if (denyRoles != null)
                denyRule.Roles.AddRange(denyRoles);
            location.Rules.Add(denyRule);

            _rootLocation.ChildLocations.Add(location);
        }
Beispiel #3
0
 public void AddRules(string locationPath, IList<AuthorizationRule> rules)
 {
     AuthorizationLocation location = new AuthorizationLocation { Path = locationPath };
     location.Rules.AddRange(rules);
     _rootLocation.ChildLocations.Add(location);
 }