protected AuthorizationRight IsAuthorized(IFubuRequest request, IEnumerable <IAuthorizationPolicy> policies,
                                                  Action <IAuthorizationPolicy, AuthorizationRight> rightsDiscoveryAction)
        {
            // Check every authorization policy for this endpoint
            var rights = policies.Select(policy =>
            {
                var policyRights = policy.RightsFor(request);


                if (rightsDiscoveryAction != null)
                {
                    rightsDiscoveryAction(policy, policyRights);
                }

                _logger.DebugMessage(() => new AuthorizationPolicyResult(policy, policyRights));

                return(policyRights);
            });

            // Combine the results
            var result = AuthorizationRight.Combine(rights);

            _logger.DebugMessage(() => new AuthorizationResult(result));

            return(result);
        }
        public virtual AuthorizationRight IsAuthorized(IFubuRequest request, IEnumerable <IAuthorizationPolicy> policies)
        {
            // Check every authorization policy for this endpoint
            var rights = policies.Select(x => x.RightsFor(request));

            // Combine the results
            return(AuthorizationRight.Combine(rights));
        }
예제 #3
0
        public AuthorizationRight IsAuthorized(IFubuRequestContext context)
        {
            if (!_policies.Any())
            {
                return(AuthorizationRight.Allow);
            }

            return(AuthorizationRight.Combine(_policies.Select(x => x.RightsFor(context))));
        }
예제 #4
0
        public AuthorizationRight DetermineRights(IFubuRequestContext context, IEnumerable <IAuthorizationPolicy> policies)
        {
            // Check every authorization policy for this endpoint
            var rights = policies.Select(policy => {
                var policyRights = policy.RightsFor(context);

                _logger.DebugMessage(() => new AuthorizationPolicyResult(policy, policyRights));

                return(policyRights);
            });

            // Combine the results
            var result = AuthorizationRight.Combine(rights);

            return(result);
        }
예제 #5
0
        public static AuthorizationRight Combine(IEnumerable <AuthorizationRight> rights)
        {
            AuthorizationRight answer = None;

            foreach (var right in rights)
            {
                if (right == Deny)
                {
                    return(right);
                }

                if (right.Precedence < answer.Precedence)
                {
                    answer = right;
                }
            }

            return(answer);
        }
예제 #6
0
 public AuthorizationResult(AuthorizationRight rights)
 {
     _rights = rights;
 }
예제 #7
0
 public AuthorizationPolicyResult(IAuthorizationPolicy policy, AuthorizationRight rights)
 {
     _rights = rights;
     _policy = Description.For(policy);
 }
 public AuthorizationRight IsAuthorized(IFubuRequest request)
 {
     return(AuthorizationRight.Combine(_policies.Select(x => x.RightsFor(request))));
 }
 public AuthorizationPolicyResult(IAuthorizationPolicy policy, AuthorizationRight rights)
 {
     _rights = rights;
     _policy = Description.For(policy);
 }
 public AuthorizationResult(AuthorizationRight rights)
 {
     _rights = rights;
 }