예제 #1
0
        /// <summary>
        ///     Adds a middleware to the OWIN pipeline that sets the Content-Security-Policy-Report-Only header.
        /// </summary>
        /// <param name="app">The <see cref="IAppBuilder" /> to which the middleware is added.</param>
        /// <param name="configurer">An <see cref="Action" /> that configures the options for the middleware.</param>
        /// <returns>The <see cref="IAppBuilder" /> supplied in the app parameter.</returns>
        public static IAppBuilder UseCspReportOnly(this IAppBuilder app, Action<IFluentCspOptions> configurer)
        {
            if (app == null) throw new ArgumentNullException("app");
            if (configurer == null) throw new ArgumentNullException("configurer");

            var options = new CspOptions();
            configurer(options);
            return app.Use(typeof (CspMiddleware), options, true); //Last param indicates it's reportOnly.
        }
예제 #2
0
        /// <summary>
        ///     Adds a middleware to the OWIN pipeline that sets the Content-Security-Policy-Report-Only header.
        /// </summary>
        /// <param name="app">The <see cref="IAppBuilder" /> to which the middleware is added.</param>
        /// <param name="configurer">An <see cref="Action" /> that configures the options for the middleware.</param>
        /// <returns>The <see cref="IAppBuilder" /> supplied in the app parameter.</returns>
        public static IAppBuilder UseCspReportOnly(this IAppBuilder app, Action <IFluentCspOptions> configurer)
        {
            if (app == null)
            {
                throw new ArgumentNullException("app");
            }
            if (configurer == null)
            {
                throw new ArgumentNullException("configurer");
            }

            var options = new CspOptions();

            configurer(options);
            return(app.Use(typeof(CspMiddleware), options, true)); //Last param indicates it's reportOnly.
        }