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)); }
public AuthorizationRight IsAuthorized(IFubuRequestContext context) { if (!_policies.Any()) { return(AuthorizationRight.Allow); } return(AuthorizationRight.Combine(_policies.Select(x => x.RightsFor(context)))); }
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); }
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); }
public AuthorizationResult(AuthorizationRight rights) { _rights = rights; }
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)))); }