Ejemplo n.º 1
0
        protected bool Authorize(HttpContextBase httpContext, bool isAllowAnonymousAttributeDefined)
        {
            if (!ProviderLimiterService.IsEnabled())
            {
                return(AuthorizeCore(httpContext));
            }

            Logger.Trace("Checking if access is allowed...");

            if (!ProviderLimiterService.HasProviderRestriction(httpContext))
            {
                Logger.Warn("Unable to determine possible provider restrictions, deny access.");
                return(false);
            }

            if (ProviderLimiterService.DoesAnUnregisteredProviderExist(httpContext))
            {
                ProviderLimiterService.RegisterProviderRestriction(httpContext);
            }

            var provider        = ProviderLimiterService.GetProviderRestriction(httpContext);
            var isAccessAllowed = string.IsNullOrWhiteSpace(provider);

            Logger.Trace((isAccessAllowed ? "Access is allowed." : "Access is not allowed. ") + " Provider: " + provider);
            return(isAccessAllowed && (isAllowAnonymousAttributeDefined || AuthorizeCore(httpContext)));
        }
Ejemplo n.º 2
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);

            if (!_providerLimiterService.IsEnabled())
            {
                return;
            }

            var httpContext = filterContext.HttpContext;

            if (_providerLimiterService.DoesAnUnregisteredProviderExist(httpContext))
            {
                _providerLimiterService.RegisterProviderRestriction(httpContext);
            }
        }