public XDownloadOptionsMiddleware(AppFunc next)
     : base(next)
 {
     _config = new SimpleBooleanConfiguration { Enabled = true };
     var headerGenerator = new HeaderGenerator();
     _headerResult = headerGenerator.CreateXDownloadOptionsResult(_config);
 }
        public XDownloadOptionsMiddleware(RequestDelegate next)
            : base(next)
        {
            _config = new SimpleBooleanConfiguration {
                Enabled = true
            };
            var headerGenerator = new HeaderGenerator();

            _headerResult = headerGenerator.CreateXDownloadOptionsResult(_config);
        }
        public XContentTypeOptionsMiddleware(AppFunc next)
            : base(next)
        {
            _config = new SimpleBooleanConfiguration {
                Enabled = true
            };
            var headerGenerator = new HeaderGenerator();

            _headerResult = headerGenerator.CreateXContentTypeOptionsResult(_config);
        }
        internal void SetNoCacheHeadersOverride(HttpContextBase context, ISimpleBooleanConfiguration setNoCacheHeadersConfig)
        {
            var headerList = GetHeaderListFromContext(context);
            const string headerKey = SetNoCacheHeadersKey;

            if (headerList.ContainsKey(headerKey))
                headerList.Remove(headerKey);

            headerList.Add(headerKey, setNoCacheHeadersConfig);
        }
        internal void SetXContentTypeOptionsOverride(HttpContextBase context, ISimpleBooleanConfiguration xContentTypeOptionsConfig)
        {
            var headerList = GetHeaderListFromContext(context);
            var headerKey = HeaderConstants.XContentTypeOptionsHeader;

            if (headerList.ContainsKey(headerKey))
                headerList.Remove(headerKey);

            headerList.Add(headerKey, xContentTypeOptionsConfig);
        }
        internal void SetXContentTypeOptionsOverride(HttpContext context, ISimpleBooleanConfiguration xContentTypeOptionsConfig)
        {
            var headerList = GetHeaderListFromContext(context);
            var headerKey  = HeaderConstants.XContentTypeOptionsHeader;

            if (headerList.ContainsKey(headerKey))
            {
                headerList.Remove(headerKey);
            }

            headerList.Add(headerKey, xContentTypeOptionsConfig);
        }
        internal void SetNoCacheHeadersOverride(HttpContext context, ISimpleBooleanConfiguration setNoCacheHeadersConfig)
        {
            var          headerList = GetHeaderListFromContext(context);
            const string headerKey  = SetNoCacheHeadersKey;

            if (headerList.ContainsKey(headerKey))
            {
                headerList.Remove(headerKey);
            }

            headerList.Add(headerKey, setNoCacheHeadersConfig);
        }
Exemple #8
0
 public HeaderResult CreateXDownloadOptionsResult(ISimpleBooleanConfiguration xDownloadOptionsConfig,
                                                  ISimpleBooleanConfiguration oldXDownloadOptionsConfig = null)
 {
     if (oldXDownloadOptionsConfig != null && oldXDownloadOptionsConfig.Enabled &&
         !xDownloadOptionsConfig.Enabled)
     {
         return(new HeaderResult(HeaderResult.ResponseAction.Remove, HeaderConstants.XDownloadOptionsHeader));
     }
     return(xDownloadOptionsConfig.Enabled
         ? new HeaderResult(HeaderResult.ResponseAction.Set, HeaderConstants.XDownloadOptionsHeader, "noopen")
         : null);
 }
 public HeaderResult CreateXDownloadOptionsResult(ISimpleBooleanConfiguration xDownloadOptionsConfig,
     ISimpleBooleanConfiguration oldXDownloadOptionsConfig = null)
 {
     if (oldXDownloadOptionsConfig != null && oldXDownloadOptionsConfig.Enabled &&
         !xDownloadOptionsConfig.Enabled)
     {
         return new HeaderResult(HeaderResult.ResponseAction.Remove, HeaderConstants.XDownloadOptionsHeader);
     }
     return xDownloadOptionsConfig.Enabled
         ? new HeaderResult(HeaderResult.ResponseAction.Set, HeaderConstants.XDownloadOptionsHeader, "noopen")
         : null;
 }
Exemple #10
0
        public HeaderResult CreateXContentTypeOptionsResult(ISimpleBooleanConfiguration xContentTypeOptionsConfig,
                                                            ISimpleBooleanConfiguration oldXContentTypeOptionsConfig = null)
        {
            if (oldXContentTypeOptionsConfig != null && oldXContentTypeOptionsConfig.Enabled &&
                !xContentTypeOptionsConfig.Enabled)
            {
                return(new HeaderResult(HeaderResult.ResponseAction.Remove, HeaderConstants.XContentTypeOptionsHeader));
            }

            return(xContentTypeOptionsConfig.Enabled
                ? new HeaderResult(HeaderResult.ResponseAction.Set, HeaderConstants.XContentTypeOptionsHeader, "nosniff")
                : null);
        }
        public HeaderResult CreateXContentTypeOptionsResult(ISimpleBooleanConfiguration xContentTypeOptionsConfig,
            ISimpleBooleanConfiguration oldXContentTypeOptionsConfig = null)
        {
            if (oldXContentTypeOptionsConfig != null && oldXContentTypeOptionsConfig.Enabled &&
                !xContentTypeOptionsConfig.Enabled)
            {
                return new HeaderResult(HeaderResult.ResponseAction.Remove, HeaderConstants.XContentTypeOptionsHeader);
            }

            return xContentTypeOptionsConfig.Enabled
                ? new HeaderResult(HeaderResult.ResponseAction.Set, HeaderConstants.XContentTypeOptionsHeader, "nosniff")
                : null;
        }
Exemple #12
0
 internal void SetXDownloadOptionsOverride(IHttpContextWrapper context, ISimpleBooleanConfiguration xDownloadOptionsConfig)
 {
     context.GetNWebsecOverrideContext().XDownloadOptions = xDownloadOptionsConfig;
 }
Exemple #13
0
 internal void SetXContentTypeOptionsOverride(IHttpContextWrapper context, ISimpleBooleanConfiguration xContentTypeOptionsConfig)
 {
     context.GetNWebsecOverrideContext().XContentTypeOptions = xContentTypeOptionsConfig;
 }
Exemple #14
0
 internal void SetNoCacheHeadersOverride(IHttpContextWrapper context, ISimpleBooleanConfiguration setNoCacheHeadersConfig)
 {
     context.GetNWebsecOverrideContext().NoCacheHeaders = setNoCacheHeadersConfig;
 }