Exemplo n.º 1
0
        /// <summary>
        /// Executes the specified policy with the given context.
        /// </summary>
        /// <param name="policyContext">The policy context.</param>
        /// <returns>
        /// <c>Off</c> unless the request contains a 'glimpsePolicy' cookie, otherwise the parsed <see cref="RuntimePolicy"/> of the cookie.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">Exception thrown if <paramref name="policyContext"/> is <c>null</c>.</exception>
        public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
        {
            var cookie = policyContext.RequestMetadata.GetCookie(ControlCookieName);

            if (string.IsNullOrEmpty(cookie))
            {
                return RuntimePolicy.Off;
            }
                
            RuntimePolicy result;

#if NET35
            if (!Glimpse.Core.Backport.Net35Backport.TryParseEnum(cookie, true, out result))
            {
                return RuntimePolicy.Off;
            }
#else
            if (!Enum.TryParse(cookie, true, out result))
            {
                return RuntimePolicy.Off;
            }
#endif

            return result;
        }
Exemplo n.º 2
0
        public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
        {
            UserInfo      user          = UserController.GetCurrentUserInfo();
            RuntimePolicy runtimePolicy = user.IsSuperUser ? RuntimePolicy.On : RuntimePolicy.Off;

            return(runtimePolicy);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Execute and apply the runtime policy.
        /// </summary>
        /// <param name="policyContext"></param>
        /// <returns></returns>
        public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
        {
            //Check web.config to see if we globally have glimpse turned on or off
            if (!DomainApplicationService.Instance.GlimpseEnabled)
            {
                return(RuntimePolicy.Off);
            }

            //Running locally, always turn glimpse on
            if (policyContext.GetHttpContext().Request.IsLocal)
            {
                return(RuntimePolicy.On);
            }

            //Otherwise make sure user is a system admin for it to be on and to get to
            //the widgets to view glimpse data
            if (DomainSessionService.Instance != null && DomainSessionService.Instance.CurrentUser != null &&
                DomainSessionService.Instance.CurrentUser.SystemAdmin)
            {
                return(RuntimePolicy.On);
            }

            //Otherwise, only collect data for glimpse from the users but dont allow them to see it.
            return(RuntimePolicy.PersistResults);
        }
        public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
        {
            UserInfo user = UserController.GetCurrentUserInfo();
            RuntimePolicy runtimePolicy = user.IsSuperUser ? RuntimePolicy.On : RuntimePolicy.Off;

            return runtimePolicy;
        }
 public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
 {
     return (policyContext != null) &&
         policyContext.GetHttpContext().CanProfile() ?
         RuntimePolicy.On :
         RuntimePolicy.Off;
 }
        public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
        {
            //You can perform a check like the one below to control Glimpse's permissions within your application.
            // More information about RuntimePolicies can be found at http://getglimpse.com/Help/Custom-Runtime-Policy
            var httpContext = policyContext.GetHttpContext();
            //if (!httpContext.User.IsInRole("Administrator"))
            //{
            //    return RuntimePolicy.Off;
            //}
            string now_path = httpContext.Request.Path.ToLower();

            //过滤的地址列表
            List <string> off_path = new List <string>();

            off_path.Add("/admin");
            off_path.Add("/admin/home/index");
            off_path.Add("/admin/tools/uploadfile");
            off_path.Add("/admin/home/center");
            if (off_path.Contains(now_path))
            {
                return(RuntimePolicy.Off);
            }

            return(RuntimePolicy.On);
        }
Exemplo n.º 7
0
        /// <summary>
        /// The execute.
        /// </summary>
        /// <param name="policyContext">The policy context.</param>
        /// <returns>
        /// The <see cref="RuntimePolicy" />.
        /// </returns>
        public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
        {
            // You can perform a check like the one below to control Glimpse's permissions within your application.
            // More information about RuntimePolicies can be found at http://getglimpse.com/Help/Custom-Runtime-Policy

            return(RuntimePolicy.On);
        }
Exemplo n.º 8
0
        public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
        {
            var httpContext = policyContext.GetHttpContext();

            //TODO: max is for test. todo: asp identity roles.
            return(httpContext.User.Identity.Name == "max" ? RuntimePolicy.On : RuntimePolicy.Off);
        }
Exemplo n.º 9
0
 public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
 {
     return((policyContext != null) &&
            policyContext.GetHttpContext().CanProfile() ?
            RuntimePolicy.On :
            RuntimePolicy.Off);
 }
Exemplo n.º 10
0
        /// <summary>
        /// Executes the specified policy with the given context.
        /// </summary>
        /// <param name="policyContext">The policy context.</param>
        /// <returns>
        /// <c>Off</c> unless the request contains a 'glimpsePolicy' cookie, otherwise the parsed <see cref="RuntimePolicy"/> of the cookie.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">Exception thrown if <paramref name="policyContext"/> is <c>null</c>.</exception>
        public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
        {
            var cookie = policyContext.RequestMetadata.GetCookie(ControlCookieName);

            if (string.IsNullOrEmpty(cookie))
            {
                return(RuntimePolicy.Off);
            }

            RuntimePolicy result;

#if NET35
            if (!Glimpse.Core.Backport.Net35Backport.TryParseEnum(cookie, true, out result))
            {
                return(RuntimePolicy.Off);
            }
#else
            if (!Enum.TryParse(cookie, true, out result))
            {
                return(RuntimePolicy.Off);
            }
#endif

            return(result);
        }
        public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
        {
            // More information about RuntimePolicies can be found at http://getglimpse.com/Help/Custom-Runtime-Policy
            var httpContext = policyContext.GetHttpContext();

            return(httpContext.User.IsAdmin() ? RuntimePolicy.On : RuntimePolicy.Off);
        }
Exemplo n.º 12
0
 public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
 {
     HttpContextBase httpContext = policyContext.GetHttpContext();
     // if (!httpContext.User.IsInRole("Administrator"))
     // {
     //     return RuntimePolicy.Off;
     // }
     return RuntimePolicy.On;
 }
        public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
        {
            var httpContext = policyContext.GetHttpContext();
            if (!httpContext.User.IsInRole("Administrator"))
            {
                return RuntimePolicy.Off;
            }

            return RuntimePolicy.On;
        }
Exemplo n.º 14
0
    public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
    {
        var httpContext = policyContext.GetHttpContext();

        if (!httpContext.User.IsInRole("canViewGlimpseData"))
        {
            return(RuntimePolicy.Off);
        }

        return(RuntimePolicy.On);
    }
Exemplo n.º 15
0
        public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
        {
            var httpContextBase = policyContext.GetHttpContext();

            if (httpContextBase == null || httpContextBase.User == null)
            {
                return(RuntimePolicy.Off);
            }

            return(httpContextBase.User.IsInRole("Admin") ? RuntimePolicy.On : RuntimePolicy.Off);
        }
 public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
 {
     // You can perform a check like the one below to control Glimpse's permissions within your application.
     // More information about RuntimePolicies can be found at http://getglimpse.com/Help/Custom-Runtime-Policy
     // var httpContext = policyContext.GetHttpContext();
     // if (!httpContext.User.IsInRole("Administrator"))
     // {
     //     return RuntimePolicy.Off;
     // }
     return(RuntimePolicy.On);
 }
Exemplo n.º 17
0
        public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
        {
            var httpContext = policyContext.GetHttpContext();

            if (!httpContext.User.IsInRole("Manager"))
            {
                return(RuntimePolicy.Off);
            }

            return(RuntimePolicy.On);
        }
        public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
        {
            // More information about RuntimePolicies can be found at http://getglimpse.com/Help/Custom-Runtime-Policy
            var httpContext = policyContext.GetHttpContext();
            if (!httpContext.User.IsAdmin())
            {
                return RuntimePolicy.Off;
            }

            return RuntimePolicy.On;
        }
Exemplo n.º 19
0
        public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
        {
            var httpContextBase = policyContext.GetHttpContext();

            if (httpContextBase == null || httpContextBase.User == null)
            {
                return RuntimePolicy.Off;
            }

            return httpContextBase.User.IsInRole("Admin") ? RuntimePolicy.On : RuntimePolicy.Off;
        }
Exemplo n.º 20
0
        public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
        {
            var httpContext = policyContext.GetHttpContext();

            if (!httpContext.User.IsInRole(Constants.AdminRole))
            {
                return(RuntimePolicy.Off);
            }

            return(RuntimePolicy.On);
        }
        public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
        {
            // You can perform a check like the one below to control Glimpse's permissions within your application.
			// More information about RuntimePolicies can be found at http://getglimpse.com/Help/Custom-Runtime-Policy
			// var httpContext = policyContext.GetHttpContext();
            // if (!httpContext.User.IsInRole("Administrator"))
			// {
            //     return RuntimePolicy.Off;
			// }

            return RuntimePolicy.On;
        }
Exemplo n.º 22
0
        public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
        {
            // You can perform a check like the one below to control Glimpse's permissions within your application.
            // More information about RuntimePolicies can be found at http://getglimpse.com/Help/Custom-Runtime-Policy
            var httpContext = policyContext.GetHttpContext();
            if (!httpContext.User.IsInRole(UserProfile.GetRoleTypeDbName(RoleType.Admin)) && !httpContext.User.IsInRole(UserProfile.GetRoleTypeDbName(RoleType.AdminLeader)))
            {
                return RuntimePolicy.Off;
            }

            return RuntimePolicy.On;
        }
Exemplo n.º 23
0
    public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
    {
        var aclManager  = DependencyResolver.Current.GetService <IAclManager>();
        var userSession = DependencyResolver.Current.GetService <IUserSession>();

        if (!aclManager.IsUserAllowed(UserAction.AccessGlimpse, userSession.GetUser()))
        {
            return(RuntimePolicy.Off);
        }

        return(RuntimePolicy.On);
    }
        public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
        {
            var request = HttpContext.Current.Request;
            var whitelistedIpAddressesValue = ConfigurationManager.AppSettings["Glimpse.Orchard.WhitelistedIpAddresses"] ?? string.Empty;
            var whitelistedIpAddresses = whitelistedIpAddressesValue.Split(new [] {";"}, StringSplitOptions.RemoveEmptyEntries);

            if (request.IsLocal || !whitelistedIpAddresses.Any()) 
            {
                return RuntimePolicy.On;
            }

            return whitelistedIpAddresses.Contains(request.UserHostAddress) ? RuntimePolicy.On : RuntimePolicy.Off;
        }
        public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
        {
            var httpContext = policyContext.GetHttpContext();

            // More information about RuntimePolicies can be found at http://getglimpse.com/Help/Custom-Runtime-Policy
            if (!httpContext.User.Identity.IsAuthenticated)
                return RuntimePolicy.Off;

            if (!httpContext.User.Identity.IsAdmin())
                return RuntimePolicy.Off;

            return RuntimePolicy.On;
        }
Exemplo n.º 26
0
        public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
        {
            var request = HttpContext.Current.Request;
            var whitelistedIpAddressesValue = ConfigurationManager.AppSettings["Orchard.Glimpse:WhitelistedIpAddresses"] ?? string.Empty;
            var whitelistedIpAddresses      = whitelistedIpAddressesValue.Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries);

            if (request.IsLocal || !whitelistedIpAddresses.Any())
            {
                return(RuntimePolicy.On);
            }

            return(whitelistedIpAddresses.Contains(request.UserHostAddress) ? RuntimePolicy.On : RuntimePolicy.Off);
        }
Exemplo n.º 27
0
 /// <summary>
 /// Executes the specified policy with the given context.
 /// </summary>
 /// <param name="policyContext">The policy context.</param>
 /// <returns>
 /// <c>On</c> if the response status code is contained on the white list, otherwise <c>Off</c>.
 /// </returns>
 /// <exception cref="System.ArgumentNullException">Exception thrown if <paramref name="policyContext"/> is <c>null</c>.</exception>
 public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
 {
     try
     {
         var statusCode = policyContext.RequestMetadata.ResponseStatusCode;
         return(StatusCodeWhiteList.Contains(statusCode) ? RuntimePolicy.On : RuntimePolicy.Off);
     }
     catch (Exception exception)
     {
         policyContext.Logger.Warn(Resources.ExecutePolicyWarning, exception, GetType());
         return(RuntimePolicy.Off);
     }
 }
Exemplo n.º 28
0
        public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
        {
            // You can perform a check like the one below to control Glimpse's permissions within your application.
            // More information about RuntimePolicies can be found at http://getglimpse.com/Help/Custom-Runtime-Policy
            FormsAuthenticationTicket ticket = new HttpContextWrapper(HttpContext.Current).GetUmbracoAuthTicket();

            if (string.IsNullOrWhiteSpace(ticket?.Name) || ticket.Expired)
            {
                return(RuntimePolicy.Off);
            }

            return(RuntimePolicy.On);
        }
        public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
        {
            // You can perform a check like the one below to control Glimpse's permissions within your application.
            // More information about RuntimePolicies can be found at http://getglimpse.com/Help/Custom-Runtime-Policy
            var httpContext = policyContext.GetHttpContext();

            if (httpContext.User.Identity.Name != "Admin")
            {
                return(RuntimePolicy.Off);
            }

            return(RuntimePolicy.On);
        }
Exemplo n.º 30
0
        public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
        {
            // You can perform a check like the one below to control Glimpse's permissions within your application.
            // More information about RuntimePolicies can be found at http://getglimpse.com/Help/Custom-Runtime-Policy
            var httpContext = policyContext.GetHttpContext();

            if (ConfigurationManager.AppSettings["Debug"].ToLower() != "true" && !httpContext.User.IsInRole("glimpse") && ConfigurationManager.AppSettings["GlimpseEnabled"].ToLower() == "true")
            {
                return(RuntimePolicy.Off);
            }

            return(RuntimePolicy.On);
        }
Exemplo n.º 31
0
 /// <summary>
 /// Executes the specified policy with the given context.
 /// </summary>
 /// <param name="policyContext">The policy context.</param>
 /// <returns>
 /// <c>On</c> if the response status code is contained on the white list, otherwise <c>Off</c>.
 /// </returns>
 /// <exception cref="System.ArgumentNullException">Exception thrown if <paramref name="policyContext"/> is <c>null</c>.</exception>
 public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
 {
     try
     {
         var statusCode = policyContext.RequestMetadata.ResponseStatusCode;
         return StatusCodeWhiteList.Contains(statusCode) ? RuntimePolicy.On : RuntimePolicy.Off;
     }
     catch (Exception exception)
     {
         policyContext.Logger.Warn(Resources.ExecutePolicyWarning, exception, GetType());
         return RuntimePolicy.Off;
     }
 }
Exemplo n.º 32
0
        public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
        {
            // You can perform a check like the one below to control Glimpse's permissions within your application.
            // More information about RuntimePolicies can be found at http://getglimpse.com/Help/Custom-Runtime-Policy
            // var httpContext = policyContext.GetHttpContext();
            // if (!httpContext.User.IsInRole("Administrator"))
            // {
            //     return RuntimePolicy.Off;
            // }

            var config = DependencyResolver.Current.GetService <IApplicationConfiguration>();

            return(config.EnableGlimpse ? RuntimePolicy.On : RuntimePolicy.Off);
        }
        public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
        {
            var httpContext = policyContext.GetHttpContext();

            // More information about RuntimePolicies can be found at http://getglimpse.com/Help/Custom-Runtime-Policy
            if (!httpContext.User.Identity.IsAuthenticated)
                return RuntimePolicy.Off;

            var applicationConfigurationProvider = DependencyResolver.Current.GetService<IApplicationConfigurationProvider>();
            var administratorAliases = applicationConfigurationProvider.GetApplicationConfiguration().AdministratorAliases;
            if (!(administratorAliases.Contains(httpContext.User.Identity.Name)))
                return RuntimePolicy.Off;

            return RuntimePolicy.On;
        }
Exemplo n.º 34
0
        /// <summary>
        /// Executes the specified policy with the given context.
        /// </summary>
        /// <param name="policyContext">The policy context.</param>
        /// <returns>
        /// <c>On</c> if the response content type is contained on the white list, otherwise <c>Off</c>.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">Exception thrown if <paramref name="policyContext"/> is <c>null</c>.</exception>
        public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
        {
            try
            {
                var contentType = policyContext.RequestMetadata.ResponseContentType.ToLowerInvariant();

                // support for the following content type strings: "text/html" & "text/html; charset=utf-8"
                return(ContentTypeWhiteList.Any(ct => contentType.Contains(ct.ToLowerInvariant())) ? RuntimePolicy.On : RuntimePolicy.Off);
            }
            catch (Exception exception)
            {
                policyContext.Logger.Warn(Resources.ExecutePolicyWarning, exception, GetType());
                return(RuntimePolicy.Off);
            }
        }
        public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
        {
            var httpContext = policyContext.GetHttpContext();
            if (!httpContext.User.IsInRole("Administrator"))
            {
                var cookie = policyContext.RequestMetadata.GetCookie("SupportCall");
                if (!string.IsNullOrEmpty(cookie))
                {
                    return RuntimePolicy.PersistResults;
                }

                return RuntimePolicy.Off;
            }

            return RuntimePolicy.On;
        }
Exemplo n.º 36
0
        public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
        {
            if (policyContext == null)
            {
                throw new ArgumentNullException("policyContext");
            }

            var httpContext = policyContext.GetRequestContext <HttpContextBase>();

            if (httpContext.Request.IsLocal)
            {
                return(RuntimePolicy.On);
            }

            return(RuntimePolicy.Off);
        }
Exemplo n.º 37
0
        /// <summary>
        /// Executes the specified policy with the given context.
        /// </summary>
        /// <param name="policyContext">The policy context.</param>
        /// <returns>
        /// <c>ModifyResponseHeaders</c> if request is an Ajax request, otherwise <c>On</c>.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">Exception thrown if <paramref name="policyContext"/> is <c>null</c>.</exception>
        public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
        {
            if (policyContext == null)
            {
                throw new ArgumentNullException("policyContext");
            }

            try
            {
                return(policyContext.RequestMetadata.RequestIsAjax ? RuntimePolicy.ModifyResponseHeaders : RuntimePolicy.On);
            }
            catch (Exception exception)
            {
                policyContext.Logger.Warn(Resources.ExecutePolicyWarning, exception, GetType());
                return(RuntimePolicy.ModifyResponseHeaders);
            }
        }
Exemplo n.º 38
0
        /// <summary>
        /// Executes the specified policy with the given context.
        /// </summary>
        /// <param name="policyContext">The policy context.</param>
        /// <returns>
        /// <c>On</c> if the response content type is contained on the white list, otherwise <c>Off</c>.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">Exception thrown if <paramref name="policyContext"/> is <c>null</c>.</exception>
        public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
        {
            try
            {
                var contentType = policyContext.RequestMetadata.ResponseContentType.ToLowerInvariant();
                
                // support for the following content type strings: "text/html" & "text/html; charset=utf-8"
                var match = ContentTypeWhiteList.FirstOrDefault(ct => contentType.Contains(ct.Item1.ToLowerInvariant()));

                return match != null ? match.Item2 : RuntimePolicy.Off;
            }
            catch (Exception exception)
            {
                policyContext.Logger.Warn(Resources.ExecutePolicyWarning, exception, GetType());
                return RuntimePolicy.Off;
            }
        }
Exemplo n.º 39
0
        public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
        {
            // You can perform a check like the one below to control Glimpse's permissions within your application.
            // More information about RuntimePolicies can be found at http://getglimpse.com/Help/Custom-Runtime-Policy
            // var httpContext = policyContext.GetHttpContext();
            // if (!httpContext.User.IsInRole("Administrator"))
            // {
            //     return RuntimePolicy.Off;
            // }

            var settings = EngineContext.Current.Resolve <GlimpseSettings>();

            if (!settings.IsEnabled)
            {
                return(RuntimePolicy.Off);
            }

            var workContext = EngineContext.Current.Resolve <IWorkContext>();

            if (!settings.ShowConsoleInAdminArea)
            {
                if (workContext.IsAdmin)
                {
                    return(RuntimePolicy.Off);
                }
            }

            if (settings.AllowAdministratorsOnly)
            {
                if (!workContext.CurrentCustomer.IsAdmin())
                {
                    return(RuntimePolicy.Off);
                }
            }

            if (!settings.EnableOnRemoteServer)
            {
                var httpContext = policyContext.GetHttpContext();
                if (!httpContext.Request.IsLocal)
                {
                    return(RuntimePolicy.Off);
                }
            }

            return(RuntimePolicy.On);
        }
Exemplo n.º 40
0
        /// <summary>
        /// Executes the specified policy with the given context.
        /// </summary>
        /// <param name="policyContext">The policy context.</param>
        /// <returns>
        /// <c>ModifyResponseHeaders</c> if request is an Ajax request, otherwise <c>On</c>.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">Exception thrown if <paramref name="policyContext"/> is <c>null</c>.</exception>
        public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
        {
            if (policyContext == null)
            {
                throw new ArgumentNullException("policyContext");
            }

            try
            {
                return policyContext.RequestMetadata.RequestIsAjax ? RuntimePolicy.ModifyResponseHeaders : RuntimePolicy.On;
            }
            catch (Exception exception)
            {
                policyContext.Logger.Warn(Resources.ExecutePolicyWarning, exception, GetType());
                return RuntimePolicy.ModifyResponseHeaders;
            }
        }
 public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
 {
     // You can perform a check like the one below to control Glimpse's permissions within your application.
     // More information about RuntimePolicies can be found at http://getglimpse.com/Help/Custom-Runtime-Policy
     // var httpContext = policyContext.GetHttpContext();
     // if (!httpContext.User.IsInRole("Administrator"))
     // {
     //     return RuntimePolicy.Off;
     // }
     //RuntimePolicy.ignore
     if (GeneratorBase.MVC.Models.CommonFunction.Instance.EnableGlimpse().ToLower() == "on")
     {
         return(RuntimePolicy.On);
     }
     else
     {
         return(RuntimePolicy.Off);
     }
 }
        public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
        {
            var httpContext = policyContext.GetHttpContext();

            // More information about RuntimePolicies can be found at http://getglimpse.com/Help/Custom-Runtime-Policy
            if (!httpContext.User.Identity.IsAuthenticated)
            {
                return(RuntimePolicy.Off);
            }

            var applicationConfigurationProvider = DependencyResolver.Current.GetService <IApplicationConfigurationProvider>();
            var administratorAliases             = applicationConfigurationProvider.GetApplicationConfiguration().AdministratorAliases;

            if (!(administratorAliases.Contains(httpContext.User.Identity.Name)))
            {
                return(RuntimePolicy.Off);
            }

            return(RuntimePolicy.On);
        }
Exemplo n.º 43
0
        public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
        {
            // You can perform a check like the one below to control Glimpse's permissions within your application.
            // More information about RuntimePolicies can be found at http://getglimpse.com/Help/Custom-Runtime-Policy
            //var httpContext = policyContext.GetHttpContext();
            //if (!httpContext.User.IsInRole("Administrator"))
            //{
            //    return RuntimePolicy.Off;
            //}

            var    httpContext = policyContext.GetHttpContext();
            string clientUrl   = httpContext.Request.ServerVariables["SERVER_NAME"];

            if (clientUrl != "localhost")
            {
                return(RuntimePolicy.Off);
            }

            return(RuntimePolicy.On);
        }
Exemplo n.º 44
0
        /// <summary>
        /// Executes the specified policy with the given context.
        /// </summary>
        /// <param name="policyContext">The policy context.</param>
        /// <returns>
        /// <c>On</c> if the request Uri is contained not matched in the black list, otherwise <c>Off</c>.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">Exception thrown if <paramref name="policyContext"/> is <c>null</c>.</exception>
        public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
        {
            try
            {
                if (UriBlackList.Count == 0)
                {
                    return(RuntimePolicy.On);
                }

                var uri = policyContext.RequestMetadata.RequestUri;

                if (UriBlackList.Any(regex => regex.IsMatch(uri)))
                {
                    return(RuntimePolicy.Off);
                }

                return(RuntimePolicy.On);
            }
            catch (Exception exception)
            {
                policyContext.Logger.Warn(Resources.ExecutePolicyWarning, exception, GetType());
                return(RuntimePolicy.Off);
            }
        }
Exemplo n.º 45
0
        /// <summary>
        /// Executes the specified policy with the given context.
        /// </summary>
        /// <param name="policyContext">The policy context.</param>
        /// <returns>
        /// <c>On</c> if the request Uri is contained not matched in the black list, otherwise <c>Off</c>.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">Exception thrown if <paramref name="policyContext"/> is <c>null</c>.</exception>
        public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
        {
            try
            {
                if (UriBlackList.Count == 0)
                {
                    return RuntimePolicy.On;
                }

                var uri = policyContext.RequestMetadata.RequestUri;

                if (UriBlackList.Any(regex => regex.IsMatch(uri)))
                {
                    return RuntimePolicy.Off;
                }

                return RuntimePolicy.On;
            }
            catch (Exception exception)
            {
                policyContext.Logger.Warn(Resources.ExecutePolicyWarning, exception, GetType());
                return RuntimePolicy.Off;
            }
        }
 public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
 {
     return UserController.GetCurrentUserInfo().IsSuperUser ? RuntimePolicy.On : RuntimePolicy.Off;
 }
Exemplo n.º 47
0
 public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
 {
     return(UserController.GetCurrentUserInfo().IsSuperUser ? RuntimePolicy.On : RuntimePolicy.Off);
 }
Exemplo n.º 48
0
 public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
 {
     return policyContext.RequestMetadata.RequestUri.ToLowerInvariant().Contains("popup=true") ? RuntimePolicy.ModifyResponseBody : RuntimePolicy.On;
 }
Exemplo n.º 49
0
 public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
 {
     var enableForAllUsers = HostController.Instance.GetBoolean("Glimpse_enableForAllUsers", false);
     return UserController.GetCurrentUserInfo().IsSuperUser || policyContext.GetHttpContext().Request.IsLocal || enableForAllUsers ? RuntimePolicy.On : RuntimePolicy.Off;
 }
Exemplo n.º 50
0
 public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
 {
     return(policyContext.RequestMetadata.RequestUri.ToLowerInvariant().Contains("popup=true") ? RuntimePolicy.ModifyResponseBody : RuntimePolicy.On);
 }
Exemplo n.º 51
0
 public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
 {
     var httpContext = policyContext.GetHttpContext();
     return IsGlimpseAllowed(httpContext) ? RuntimePolicy.On : RuntimePolicy.Off;
 }
Exemplo n.º 52
0
 /// <summary>
 /// Executes the specified policy with the given context.
 /// </summary>
 /// <param name="policyContext">The policy context.</param>
 /// <returns>
 /// <c>ExecuteResourceOnly</c>.
 /// </returns>
 /// <exception cref="System.ArgumentNullException">Exception thrown if <paramref name="policyContext"/> is <c>null</c>.</exception>
 public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
 {
     return RuntimePolicy.ExecuteResourceOnly; // Don't run Glimpse methods except to execute resource.
 }
Exemplo n.º 53
0
 public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
 {
     return Execute(policyContext.GetRequestContext<HttpContextBase>());
 }
 public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
 {
     var httpContext = policyContext.GetHttpContext();
     return httpContext.User.IsAdmin() ? RuntimePolicy.On : RuntimePolicy.Off;
 }