Exemple #1
0
        internal static object ToJsonModel(Site site, string path)
        {
            var section = GetDirectoryBrowseSection(site, path);

            DirectoryBrowsingId dirbId = new DirectoryBrowsingId(site?.Id, path, section.IsLocallyStored);

            DirectoryBrowseShowFlags showFlags = section.ShowFlags;

            Dictionary <string, bool> showDictionary = new Dictionary <string, bool>();

            showDictionary.Add("date", showFlags.HasFlag(DirectoryBrowseShowFlags.Date));
            showDictionary.Add("time", showFlags.HasFlag(DirectoryBrowseShowFlags.Time));
            showDictionary.Add("size", showFlags.HasFlag(DirectoryBrowseShowFlags.Size));
            showDictionary.Add("extension", showFlags.HasFlag(DirectoryBrowseShowFlags.Extension));
            showDictionary.Add("long_date", showFlags.HasFlag(DirectoryBrowseShowFlags.LongDate));

            var obj = new {
                id                 = dirbId.Uuid,
                scope              = site == null ? string.Empty : site.Name + path,
                metadata           = ConfigurationUtility.MetadataToJson(section.IsLocallyStored, section.IsLocked, section.OverrideMode, section.OverrideModeEffective),
                enabled            = section.Enabled,
                allowed_attributes = showDictionary,
                website            = SiteHelper.ToJsonModelRef(site),
            };

            return(Environment.Hal.Apply(Defines.Resource.Guid, obj));
        }
Exemple #2
0
        internal static object ToJsonModel(Site site, string path)
        {
            var urlSection = GetUrlCompressionSection(site, path);

            // Http Compression section has 'allowDefinition="AppHostOnly"' which means it can only be edited at webserver level
            // We factor this in when displaying the metadata
            var httpSection = GetHttpCompressionSection(site, path);

            bool         isLocal               = urlSection.IsLocallyStored || httpSection.IsLocallyStored;
            bool         isLocked              = urlSection.IsLocked;
            OverrideMode overrideMode          = urlSection.OverrideMode;
            OverrideMode overrideModeEffective = urlSection.OverrideModeEffective;


            CompressionId compressionId = new CompressionId(site?.Id, path, isLocal);

            var obj = new {
                id        = compressionId.Uuid,
                scope     = site == null ? string.Empty : site.Name + path,
                metadata  = ConfigurationUtility.MetadataToJson(isLocal, isLocked, overrideMode, overrideModeEffective),
                directory = httpSection.Directory,
                do_disk_space_limitting = httpSection.DoDiskSpaceLimiting,
                max_disk_space_usage    = httpSection.MaxDiskSpaceUsage,
                min_file_size           = httpSection.MinFileSizeForComp,
                do_dynamic_compression  = urlSection.DoDynamicCompression,
                do_static_compression   = urlSection.DoStaticCompression,
                website = SiteHelper.ToJsonModelRef(site)
            };

            return(Environment.Hal.Apply(Defines.Resource.Guid, obj));
        }
        internal static object ToJsonModel(Site site, string path)
        {
            var section = GetRequestFilteringSection(site, path);

            RequestFilteringId reqId = new RequestFilteringId(site?.Id, path, section.IsLocallyStored);

            var verbs = section.Verbs.Select(v => new {
                name    = v.Verb,
                allowed = v.Allowed
            });

            var obj = new {
                id       = reqId.Uuid,
                scope    = site == null ? string.Empty : site.Name + path,
                metadata = ConfigurationUtility.MetadataToJson(section.IsLocallyStored, section.IsLocked, section.OverrideMode, section.OverrideModeEffective),
                allow_unlisted_file_extensions = section.FileExtensions.AllowUnlisted,
                allow_unlisted_verbs           = section.Verbs.AllowUnlisted,
                allow_high_bit_characters      = section.AllowHighBitCharacters,
                allow_double_escaping          = section.AllowDoubleEscaping,
                max_content_length             = section.RequestLimits.MaxAllowedContentLength,
                max_url_length          = section.RequestLimits.MaxUrl,
                max_query_string_length = section.RequestLimits.MaxQueryString,
                verbs   = verbs,
                website = SiteHelper.ToJsonModelRef(site)
            };

            return(Core.Environment.Hal.Apply(Defines.Resource.Guid, obj));
        }
        internal static object ToJsonModel(Site site, string path)
        {
            HandlersSection section = GetHandlersSection(site, path);

            HandlersId id = new HandlersId(site?.Id, path, section.IsLocallyStored);

            // Access Policy
            HandlerAccessPolicy accessPolicy = section.AccessPolicy;

            Dictionary <string, bool> allowedAccess = new Dictionary <string, bool>();

            allowedAccess.Add("read", accessPolicy.HasFlag(HandlerAccessPolicy.Read));
            allowedAccess.Add("write", accessPolicy.HasFlag(HandlerAccessPolicy.Write));
            allowedAccess.Add("execute", accessPolicy.HasFlag(HandlerAccessPolicy.Execute));
            allowedAccess.Add("source", accessPolicy.HasFlag(HandlerAccessPolicy.Source));
            allowedAccess.Add("script", accessPolicy.HasFlag(HandlerAccessPolicy.Script));

            Dictionary <string, bool> remoteAccessPrevention = new Dictionary <string, bool>();

            remoteAccessPrevention.Add("write", accessPolicy.HasFlag(HandlerAccessPolicy.NoRemoteWrite));
            remoteAccessPrevention.Add("read", accessPolicy.HasFlag(HandlerAccessPolicy.NoRemoteRead));
            remoteAccessPrevention.Add("execute", accessPolicy.HasFlag(HandlerAccessPolicy.NoRemoteExecute));
            remoteAccessPrevention.Add("script", accessPolicy.HasFlag(HandlerAccessPolicy.NoRemoteScript));

            var obj = new {
                id                       = id.Uuid,
                scope                    = site == null ? string.Empty : site.Name + path,
                metadata                 = ConfigurationUtility.MetadataToJson(section.IsLocallyStored, section.IsLocked, section.OverrideMode, section.OverrideModeEffective),
                allowed_access           = allowedAccess,
                remote_access_prevention = remoteAccessPrevention,
                website                  = SiteHelper.ToJsonModelRef(site)
            };

            return(Core.Environment.Hal.Apply(Defines.Resource.Guid, obj));
        }
Exemple #5
0
        internal static object ToJsonModel(Site site, string path)
        {
            if (site == null)
            {
                throw new ArgumentException("site");
            }

            var section = GetAccessSection(site, path);

            bool         isLocal               = section.IsLocallyStored;
            bool         isLocked              = section.IsLocked;
            OverrideMode overrideMode          = section.OverrideMode;
            OverrideMode overrideModeEffective = section.OverrideModeEffective;

            HttpAccessSslFlags        sslFlags = section.SslFlags;
            ClientCertificateSettings clientCertSettings;

            if (sslFlags.HasFlag(HttpAccessSslFlags.SslRequireCert))
            {
                clientCertSettings = ClientCertificateSettings.REQUIRE;
            }
            else if (sslFlags.HasFlag(HttpAccessSslFlags.SslNegotiateCert))
            {
                clientCertSettings = ClientCertificateSettings.ACCEPT;
            }
            else
            {
                clientCertSettings = ClientCertificateSettings.IGNORE;
            }

            bool hasHttpsBinding = false;

            if (!(site == null))
            {
                foreach (Binding binding in site.Bindings)
                {
                    if (binding.Protocol.Equals("https", StringComparison.OrdinalIgnoreCase))
                    {
                        hasHttpsBinding = true;
                        break;
                    }
                }
            }

            SslSettingId id = new SslSettingId(site?.Id, path, isLocal);

            var obj = new {
                id                  = id.Uuid,
                scope               = site == null ? string.Empty : site.Name + path,
                metadata            = ConfigurationUtility.MetadataToJson(isLocal, isLocked, overrideMode, overrideModeEffective),
                require_ssl         = sslFlags.HasFlag(HttpAccessSslFlags.Ssl) || sslFlags.HasFlag(HttpAccessSslFlags.Ssl128),
                client_certificates = Enum.GetName(typeof(ClientCertificateSettings), clientCertSettings).ToLower(),
                has_https_binding   = hasHttpsBinding,
                website             = SiteHelper.ToJsonModelRef(site)
            };

            return(Core.Environment.Hal.Apply(Defines.Resource.Guid, obj));
        }
Exemple #6
0
        public static object SectionToJsonModel(Site site, string path, Fields fields = null, bool full = true)
        {
            if (fields == null)
            {
                fields = Fields.All;
            }

            RewriteId id      = new RewriteId(site?.Id, path);
            var       section = GetSection(site, path);

            dynamic obj = new ExpandoObject();

            //
            // id
            if (fields.Exists("id"))
            {
                obj.id = id.Uuid;
            }

            //
            // scope
            if (fields.Exists("scope"))
            {
                obj.scope = site == null ? string.Empty : site.Name + path;
            }

            //
            // use_original_url_encoding
            if (fields.Exists("use_original_url_encoding") && section.Schema.HasAttribute(InboundRulesSection.UseOriginalUrlEncodingAttribute))
            {
                obj.use_original_url_encoding = section.UseOriginalURLEncoding;
            }

            //
            // metadata
            if (fields.Exists("metadata"))
            {
                obj.metadata = ConfigurationUtility.MetadataToJson(section.IsLocallyStored, section.IsLocked, section.OverrideMode, section.OverrideModeEffective);
            }

            //
            // url_rewrite
            if (fields.Exists("url_rewrite"))
            {
                obj.url_rewrite = RewriteHelper.ToJsonModelRef(site, path);
            }

            return(Core.Environment.Hal.Apply(Defines.InboundRulesSectionResource.Guid, obj, full));
        }
        public static object SectionToJsonModel(Site site, string path, Fields fields = null, bool full = true)
        {
            if (fields == null)
            {
                fields = Fields.All;
            }

            RewriteId id      = new RewriteId(site?.Id, path);
            var       section = GetSection(site, path);

            dynamic obj = new ExpandoObject();

            //
            // id
            if (fields.Exists("id"))
            {
                obj.id = id.Uuid;
            }

            //
            // scope
            if (fields.Exists("scope"))
            {
                obj.scope = site == null ? string.Empty : site.Name + path;
            }

            //
            // metadata
            if (fields.Exists("metadata"))
            {
                obj.metadata = ConfigurationUtility.MetadataToJson(section.IsLocallyStored, section.IsLocked, section.OverrideMode, section.OverrideModeEffective);
            }

            //
            // rewrite_before_cache
            if (fields.Exists("rewrite_before_cache"))
            {
                obj.rewrite_before_cache = section.RewriteBeforeCache;
            }

            //
            // url_rewrite
            if (fields.Exists("url_rewrite"))
            {
                obj.url_rewrite = RewriteHelper.ToJsonModelRef(site, path);
            }

            return(Core.Environment.Hal.Apply(Defines.OutboundRulesSectionResource.Guid, obj, full));
        }
        internal static object ModuleFeatureToJsonModel(Site site, string path)
        {
            ModulesSection section = GetModulesSection(site, path);

            ModulesId id = new ModulesId(site?.Id, path, section.IsLocallyStored);

            var obj = new {
                id       = id.Uuid,
                scope    = site == null ? string.Empty : site.Name + path,
                metadata = ConfigurationUtility.MetadataToJson(section.IsLocallyStored, section.IsLocked, section.OverrideMode, section.OverrideModeEffective),
                run_all_managed_modules_for_all_requests = section.RunAllManagedModulesForAllRequests,
                website = SiteHelper.ToJsonModelRef(site)
            };

            return(Core.Environment.Hal.Apply(Defines.ModulesResource.Guid, obj));
        }
Exemple #9
0
        internal static object ToJsonModel(Site site, string path)
        {
            HttpProtocolSection section = GetSection(site, path);

            HttpResponseHeadersId id = new HttpResponseHeadersId(site?.Id, path, section.IsLocallyStored);

            var obj = new {
                id               = id.Uuid,
                scope            = site == null ? string.Empty : site.Name + path,
                metadata         = ConfigurationUtility.MetadataToJson(section.IsLocallyStored, section.IsLocked, section.OverrideMode, section.OverrideModeEffective),
                allow_keep_alive = section.AllowKeepAlive,
                website          = SiteHelper.ToJsonModelRef(site)
            };

            return(Core.Environment.Hal.Apply(Defines.Resource.Guid, obj));
        }
        public static object ToJsonModel(Site site, string path)
        {
            RewriteId serverVariablesId = new RewriteId(site?.Id, path);
            var       section           = GetSection(site, path);

            var obj = new
            {
                id          = serverVariablesId.Uuid,
                scope       = site == null ? string.Empty : site.Name + path,
                entries     = section.AllowedServerVariables.Select(v => v.Name),
                metadata    = ConfigurationUtility.MetadataToJson(section.IsLocallyStored, section.IsLocked, section.OverrideMode, section.OverrideModeEffective),
                url_rewrite = RewriteHelper.ToJsonModelRef(site, path)
            };

            return(Environment.Hal.Apply(Defines.ServerVariablesResource.Guid, obj));
        }
        internal static object ToJsonModel(Site site, string path)
        {
            var section = GetDefaultDocumentSection(site, path);

            // Construct id passing possible site and application associated
            DefaultDocumentId docId = new DefaultDocumentId(site?.Id, path, section.IsLocallyStored);

            var obj = new {
                id       = docId.Uuid,
                enabled  = section.Enabled,
                scope    = site == null ? string.Empty : site.Name + path,
                metadata = ConfigurationUtility.MetadataToJson(section.IsLocallyStored, section.IsLocked, section.OverrideMode, section.OverrideModeEffective),
                website  = SiteHelper.ToJsonModelRef(site)
            };

            return(Environment.Hal.Apply(Defines.Resource.Guid, obj));
        }
        public static object ToJsonModel(Site site, string path)
        {
            var section = GetSection(site, path);

            // Construct id passing possible site and application associated
            AnonAuthId id = new AnonAuthId(site?.Id, path, section.IsLocallyStored);

            var obj = new {
                id       = id.Uuid,
                enabled  = section.Enabled,
                scope    = site == null ? string.Empty : site.Name + path,
                metadata = ConfigurationUtility.MetadataToJson(section.IsLocallyStored, section.IsLocked, section.OverrideMode, section.OverrideModeEffective),
                user     = section.UserName,
                website  = site == null ? null : SiteHelper.ToJsonModelRef(site),
            };

            return(Core.Environment.Hal.Apply(Defines.AnonAuthResource.Guid, obj));
        }
        public static object ToJsonModel(Site site, string path)
        {
            var section = GetRedirectSection(site, path);
            var redId   = new RedirectId(site?.Id, path, section.IsLocallyStored);

            var obj = new {
                id                = redId.Uuid,
                enabled           = section.Enabled,
                preserve_filename = section.ChildOnly,
                destination       = section.Destination,
                absolute          = section.ExactDestination,
                status_code       = (int)section.HttpResponseStatus,
                scope             = site == null ? string.Empty : site.Name + path,
                metadata          = ConfigurationUtility.MetadataToJson(section.IsLocallyStored, section.IsLocked, section.OverrideMode, section.OverrideModeEffective),
                website           = SiteHelper.ToJsonModelRef(site)
            };

            return(Environment.Hal.Apply(Defines.Resource.Guid, obj));
        }
        internal static object ToJsonModel(Site site, string path)
        {
            var section = GetSection(site, path);

            StaticContentId id = new StaticContentId(site?.Id, path, section.IsLocallyStored);

            var obj = new {
                id                      = id.Uuid,
                scope                   = site == null ? string.Empty : site.Name + path,
                metadata                = ConfigurationUtility.MetadataToJson(section.IsLocallyStored, section.IsLocked, section.OverrideMode, section.OverrideModeEffective),
                client_cache            = CacheToJsonModel(section.ClientCache),
                default_doc_footer      = section.DefaultDocFooter,
                is_doc_footer_file_name = section.IsDocFooterFileName,
                enable_doc_footer       = section.EnableDocFooter,
                website                 = SiteHelper.ToJsonModelRef(site)
            };

            return(Core.Environment.Hal.Apply(Defines.Resource.Guid, obj));
        }
        internal static object ToJsonModel(Site site, string path)
        {
            var section          = GetTraceFailedRequestsSection(site, path);
            var providersSection = GetTraceProviderDefinitionSection(site, path);

            bool         isLocal               = section.IsLocallyStored;
            bool         isLocked              = section.IsLocked;
            OverrideMode overrideMode          = section.OverrideMode;
            OverrideMode overrideModeEffective = section.OverrideModeEffective;

            HttpRequestTracingId hrtId = new HttpRequestTracingId(site?.Id, path, isLocal);

            bool   enabled;
            string directory = null;
            long   maximumNumberTraceFiles;

            if (site != null)
            {
                enabled   = site.TraceFailedRequestsLogging.Enabled;
                directory = site.TraceFailedRequestsLogging.Directory;
                maximumNumberTraceFiles = site.TraceFailedRequestsLogging.MaxLogFiles;
            }
            else
            {
                var siteDefaults = ManagementUnit.ServerManager.SiteDefaults;
                enabled   = true;
                directory = siteDefaults.TraceFailedRequestsLogging.Directory;
                maximumNumberTraceFiles = siteDefaults.TraceFailedRequestsLogging.MaxLogFiles;
            }

            var obj = new {
                id        = hrtId.Uuid,
                scope     = site == null ? string.Empty : site.Name + path,
                metadata  = ConfigurationUtility.MetadataToJson(isLocal, isLocked, overrideMode, overrideModeEffective),
                enabled   = enabled,
                directory = directory,
                maximum_number_trace_files = maximumNumberTraceFiles,
                website = SiteHelper.ToJsonModelRef(site)
            };

            return(Environment.Hal.Apply(Defines.Resource.Guid, obj));
        }
Exemple #16
0
        public static object ToJsonModel(Site site, string path)
        {
            var section = GetSection(site, path);

            // Construct id passing possible site and application associated
            WinAuthId id = new WinAuthId(site?.Id, path, section.IsLocallyStored);

            var obj = new {
                id              = id.Uuid,
                enabled         = section.Enabled,
                scope           = site == null ? string.Empty : site.Name + path,
                metadata        = ConfigurationUtility.MetadataToJson(section.IsLocallyStored, section.IsLocked, section.OverrideMode, section.OverrideModeEffective),
                use_kernel_mode = section.UseKernelMode,
                token_checking  = Enum.GetName(typeof(TokenChecking), section.TokenCheckingAttribute).ToLower(),
                providers       = ProvidersJsonModel(section),
                website         = site == null ? null : SiteHelper.ToJsonModelRef(site)
            };

            return(Core.Environment.Hal.Apply(Defines.WinAuthResource.Guid, obj));
        }
        internal static object ToJsonModel(Site site, string path)
        {
            var section = GetSection(site, path);

            // Set up metadata, this feature has two configuration sections
            bool         isLocal               = section.IsLocallyStored;
            bool         isLocked              = section.IsLocked;
            OverrideMode overrideMode          = section.OverrideMode;
            OverrideMode overrideModeEffective = section.OverrideModeEffective;


            AuthorizationId id = new AuthorizationId(site?.Id, path, isLocal);

            var obj = new {
                id                 = id.Uuid,
                scope              = site == null ? string.Empty : site.Name + path,
                metadata           = ConfigurationUtility.MetadataToJson(isLocal, isLocked, overrideMode, overrideModeEffective),
                bypass_login_pages = section.BypassLoginPages,
                website            = SiteHelper.ToJsonModelRef(site)
            };

            return(Core.Environment.Hal.Apply(Defines.AuthorizationResource.Guid, obj));
        }
        internal static object ToJsonModel(Site site, string path)
        {
            LogSection         logSection     = GetLogSection(site, path);
            HttpLoggingSection httpLogSection = GetHttpLoggingSection(site, path);

            SiteLogFile logFile = null;

            if (site == null)
            {
                logFile = ManagementUnit.Current.ServerManager.SiteDefaults.LogFile;
            }
            else
            {
                logFile = site.LogFile;
            }

            LoggingId id = new LoggingId(site?.Id, path, httpLogSection.IsLocallyStored);

            Dictionary <string, bool> logTargetW3C = new Dictionary <string, bool>();

            if (logFile.Schema.HasAttribute(LogTargetW3CAttribute))
            {
                LogTargetW3C target = logFile.LogTargetW3C;

                logTargetW3C.Add("etw", target.HasFlag(LogTargetW3C.ETW));
                logTargetW3C.Add("file", target.HasFlag(LogTargetW3C.File));
            }

            FileLogFormat logFormat;

            if (logSection.CentralLogFileMode == CentralLogFileMode.Site)
            {
                logFormat = FromLogFormat(logFile.LogFormat);
            }
            else
            {
                logFormat = logSection.CentralLogFileMode == CentralLogFileMode.CentralBinary ? FileLogFormat.Binary : FileLogFormat.W3c;
            }


            bool logFilePerSite = logSection.CentralLogFileMode == CentralLogFileMode.Site;

            string directory    = default(string);
            string period       = default(string);
            long   truncateSize = default(long);
            bool   useLocalTime = default(bool);
            Dictionary <string, bool> logTargetW3c    = default(Dictionary <string, bool>);
            Dictionary <string, bool> logFields       = default(Dictionary <string, bool>);
            IEnumerable <object>      customLogFields = default(IEnumerable <object>);

            switch (logSection.CentralLogFileMode)
            {
            case CentralLogFileMode.CentralBinary:

                directory       = logSection.CentralBinaryLogFile.Directory;
                period          = PeriodRepresentation(logSection.CentralBinaryLogFile.Period);
                truncateSize    = logSection.CentralBinaryLogFile.TruncateSize;
                useLocalTime    = logSection.CentralBinaryLogFile.LocalTimeRollover;
                logTargetW3c    = null;
                logFields       = null;
                customLogFields = null;
                break;

            case CentralLogFileMode.CentralW3C:

                directory       = logSection.CentralW3CLogFile.Directory;
                period          = PeriodRepresentation(logSection.CentralW3CLogFile.Period);
                truncateSize    = logSection.CentralW3CLogFile.TruncateSize;
                useLocalTime    = logSection.CentralW3CLogFile.LocalTimeRollover;
                logTargetW3c    = null;
                logFields       = LogExtFileFlagsRepresentation(logSection.CentralW3CLogFile.LogExtFileFlags);
                customLogFields = null;

                break;

            case CentralLogFileMode.Site:

                directory    = logFile.Directory;
                period       = PeriodRepresentation(logFile.Period);
                truncateSize = logFile.TruncateSize;
                useLocalTime = logFile.LocalTimeRollover;
                logTargetW3c = logTargetW3C;
                logFields    = LogExtFileFlagsRepresentation(logFile.LogExtFileFlags);

                if (logFile.Schema.HasChildElement(CustomFieldsElement))
                {
                    customLogFields = logFile.CustomLogFields.Select(custField => {
                        return(new
                        {
                            field_name = custField.LogFieldName,
                            source_name = custField.SourceName,
                            source_type = SourceTypeRepresentation(custField.SourceType)
                        });
                    });
                }

                break;
            }

            dynamic o = new ExpandoObject();

            o.id    = id.Uuid;
            o.scope = site == null ? string.Empty : site.Name + path;

            // The metadata is obtained solely from <httpLogSection> because the <log> section is in applicationHost/* path which means it can't be accessed in web configs
            o.metadata = ConfigurationUtility.MetadataToJson(httpLogSection.IsLocallyStored, httpLogSection.IsLocked, httpLogSection.OverrideMode, httpLogSection.OverrideModeEffective);

            o.enabled      = IsLoggingEnabled(httpLogSection, logSection, logFile);
            o.log_per_site = logFilePerSite;

            o.directory         = directory;
            o.log_file_encoding = logSection.LogInUTF8 ? "utf-8" : "ansi";
            o.log_file_format   = Enum.GetName(typeof(FileLogFormat), logFormat).ToLower();

            if (logFile.Schema.HasAttribute(LogTargetW3CAttribute))
            {
                o.log_target = logTargetW3c;
            }

            o.log_fields = logFields;

            if (logFile.Schema.HasChildElement(CustomFieldsElement))
            {
                o.custom_log_fields = customLogFields;
            }

            o.rollover = new
            {
                period         = period,
                truncate_size  = truncateSize,
                use_local_time = useLocalTime,
            };

            o.website = SiteHelper.ToJsonModelRef(site);

            return(Core.Environment.Hal.Apply(Defines.Resource.Guid, o));
        }
        internal static object ToJsonModel(Site site, string path)
        {
            // Dynamic ip security section added in iis 8.0
            var hasDynamic = ManagementUnit.ServerManager.GetApplicationHostConfiguration().HasSection(IPRestrictionsGlobals.DynamicIPSecuritySectionName);

            var section = GetSection(site, path);
            DynamicIPSecuritySection dynamicSection = null;

            bool isLocal;
            bool isLocked;
            bool isEnabled;

            OverrideMode overrideMode;
            OverrideMode overrideModeEffective;

            isLocal   = section.IsLocallyStored;
            isLocked  = section.IsLocked;
            isEnabled = section.IpAddressFilters.Count != 0 ||
                        section.EnableReverseDns ||
                        !section.AllowUnlisted;

            if (section.Schema.HasAttribute(EnableProxyModeAttribute))
            {
                isEnabled = isEnabled || section.EnableProxyMode;
            }

            overrideMode          = section.OverrideMode;
            overrideModeEffective = section.OverrideModeEffective;


            if (hasDynamic)
            {
                dynamicSection = GetDynamicSecuritySection(site, path);

                isLocal   = isLocal || dynamicSection.IsLocallyStored;
                isLocked  = isLocked || dynamicSection.IsLocked;
                isEnabled = isEnabled || dynamicSection.DenyByConcurrentRequests.Enabled ||
                            dynamicSection.DenyByRequestRate.Enabled;

                overrideMode          = section.OverrideMode != dynamicSection.OverrideMode ? OverrideMode.Unknown : section.OverrideMode;
                overrideModeEffective = section.OverrideModeEffective != dynamicSection.OverrideModeEffective ? OverrideMode.Unknown : section.OverrideModeEffective;
            }

            // Construct id passing possible site and application associated
            IPRestrictionId ipId = new IPRestrictionId(site?.Id, path, isLocal);

            dynamic obj = new ExpandoObject();

            obj.id                 = ipId.Uuid;
            obj.scope              = site == null ? string.Empty : site.Name + path;
            obj.enabled            = isEnabled;
            obj.metadata           = ConfigurationUtility.MetadataToJson(isLocal, isLocked, overrideMode, overrideModeEffective);
            obj.allow_unlisted     = section.AllowUnlisted;
            obj.enable_reverse_dns = section.EnableReverseDns;

            if (section.Schema.HasAttribute(EnableProxyModeAttribute))
            {
                obj.enable_proxy_mode = section.EnableProxyMode;
            }

            if (section.Schema.HasAttribute(DenyActionAttribute))
            {
                obj.deny_action = Enum.GetName(typeof(DenyActionType), section.DenyAction);
            }

            if (hasDynamic)
            {
                obj.deny_by_concurrent_requests = new
                {
                    enabled = dynamicSection.DenyByConcurrentRequests.Enabled,
                    max_concurrent_requests = dynamicSection.DenyByConcurrentRequests.MaxConcurrentRequests
                };
                obj.deny_by_request_rate = new
                {
                    enabled      = dynamicSection.DenyByRequestRate.Enabled,
                    max_requests = dynamicSection.DenyByRequestRate.MaxRequests,
                    time_period  = dynamicSection.DenyByRequestRate.TimePeriod
                };
                obj.logging_only_mode = dynamicSection.LoggingOnlyMode;
            }
            obj.website = SiteHelper.ToJsonModelRef(site);


            return(Core.Environment.Hal.Apply(Defines.Resource.Guid, obj));
        }