/// <summary>
        /// Constructs the header.
        /// </summary>
        /// <param name="settings">The settings.</param>
        /// <param name="context">The context.</param>
        private static void ConstructHeader(StrictTransportSecurityOptions settings, IOwinContext context)
        {
            var options  = settings;
            var response = context.Response;

            response.Headers[StrictTransportSecurityHeaderName] = ConstructHeaderValue(options);
        }
        /// <summary>
        /// Constructs the header value.
        /// </summary>
        /// <param name="options">The options.</param>
        /// <returns>constructed header string</returns>
        private static string ConstructHeaderValue(StrictTransportSecurityOptions options)
        {
            var age        = MaxAgeDirective(options.MaxAge);
            var subDomains = IncludeSubDomainsDirective(options.IncludeSubDomains);
            var preload    = PreloadDirective(options.Preload);

            return($"{age}{subDomains}{preload}");
        }
Пример #3
0
 public static void UseStrictTransportSecuritySettings(this IAppBuilder app, StrictTransportSecurityOptions options)
 {
     app.Use <StrictTransportSecurityMiddleware>(options);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="StrictTransportSecurityMiddleware"/> class.
 /// </summary>
 /// <param name="next">The next.</param>
 /// <param name="options">Strict-Transport-Security header optionons.</param>
 public StrictTransportSecurityMiddleware(OwinMiddleware next, StrictTransportSecurityOptions options) : base(next)
 {
     this.settings = options;
 }