Exemple #1
0
        public virtual IActionResult Access_Submit(IFormCollection form)
        {
            var model = _routeAnalyzer.GetAllRouteInformations().OrderBy(p => p.Controller).ToList();

            foreach (var item in model)
            {
                var key = "disable_" + item.Path;

                var disable = form.ContainsKey(key) && form[key].ToString() == "on";

                RouteMemoryStore.Set(new Unity.Firewall.RouteItem {
                    Route = item.Path, IsDisable = disable
                });
            }


            return(RedirectToAction("Access"));
        }
Exemple #2
0
        public bool IsAllowed()
        {
            if (_actionExecutingContext == null || _cache == null || _current == null)
            {
                return(true);
            }

            // 获取路由
            var actionDescriptor = _actionExecutingContext.ActionDescriptor as ControllerActionDescriptor;
            var route            = actionDescriptor?.AttributeRouteInfo?.Template;

            if (string.IsNullOrEmpty(route))
            {
                return(true);
            }

            route = $"/" + route;
            RouteItem routeItem = RouteMemoryStore.Get(route);

            bool isAllowed = routeItem == null || !routeItem.IsDisable;

            return(isAllowed);
        }