ASP-WAF Web application firewall for .Net 5, .Net Standard 2.1 and .Net Core 3.x

HeaderConfig Class

This allows you to manages header configurations for those headers that are generated and used by the firewall

Namespace:  Walter.Web.FireWall.Configurations
Assembly:  Walter.Web.FireWall (in Walter.Web.FireWall.dll)

Syntax


public sealed class HeaderConfig : ISecurityHeadersBuilder

Examples


Bellow sample shows longer sample of code that configures the firewall as well as enabled CSP and XSS browser based security
C#
services.AddFireWall("Your Token", "Domain Key", domainName: new Uri("https://www.test.dll", UriKind.Absolute), options => {
       options.JoinCustomerImprovementProgramWithEmail = "mail@test.dll";
       options.Cypher.ApplicationPassword = "123456Seven";
       options.ApplicationName = "www.test.dll";
       options.ApplicationTag = "WS3";
       options.Rules.AllowWhiteListing = false;
       //view located in ~/Views/Shared
       options.Reporting.HealthReportView = "_healthReport";
       options.Reporting.EmailReportView = "_EmailReport";

       options.WebServices.IsUserApiUrl = new Uri(Links.IsUserEndpoint, UriKind.Relative);
       options.WebServices.RegisterLinksApiUrl = new Uri(Links.SiteMapEndPoint, UriKind.Relative);
       options.WebServices.BeaconApiUrl = new Uri(Links.BeaconPoint, UriKind.Relative);
       options.WebServices.CSPReportUrl = new Uri(Links.CSPViolation, UriKind.Relative);

       options.Cashing.GeoLocation.SlidingExpiration = TimeSpan.FromMinutes(20);

       options.Rules.BlockRequest.BlockDuration.SlideExpiration = true;
       options.Rules.BlockRequest.BlockDuration.Expires = TimeSpan.FromSeconds(10);
       options.Rules.AllowWhiteListing = false;
       options.Rules.Headers.AddDefaultSecurePolicy()
                             .AddStrictTransportSecurityNoCache()
                             .AddXssProtectionBlockAndReport()
                             .AddContentSecurityPolicyButTrust(trustingSites: TrustingSites.Jquery | TrustingSites.Google
                                       , allowInline: true
                                       , framesPolicy: FramesPolicy.Self);

   //continue configuring add-ons for the firewall
     }).UseGeography(new System.IO.DirectoryInfo("D:\\MaxMind"))
      .UseDiskLogging(options => { options.Directory = @"D:\Firewall"; })
      .UserDatabase(DatabaseConnections.FireWallState)
      .UseFireWallReportingDatabase(DatabaseConnections.FireWall)
      .UseSMTPReportingDatabase(DatabaseConnections.FireWallMail, options =>
       {
           options.Archive = TimeSpan.FromDays(180);
           options.Server = "mail.asp-waf.com";
           options.UserName = "noreply@test.dll";
           options.Password = "Jhagga$ki82#@test.dll";
           options.Port = 25;
           options.From = "noreply@@test.dll";
           options.IgnoreServerCertificateErrors = true;
           options.DefaultEmail = "owner@@test.dll";
           options.Archive = TimeSpan.FromDays(60);
           options.MailingList.AddRange(new[] {
            new EMailAddress("Security Admin","security@@test.dll") {
                Frequency= TimeSpan.FromHours(1),
                Roles= EMailRoles.FireWallAdministrationViolations | EMailRoles.UnauthorizedPhysicalFilesViolation } ,
            new EMailAddress("Website Admin","WebMaster@@test.dll"){
                Frequency= TimeSpan.FromHours(1),
                Roles= EMailRoles.ProductUpdates | EMailRoles.OwnAccountRelatedViolations } ,
             });
     });
   //use filter on each request instead of middleware
   services.AddMvc(options =>  options.Filters.Add<Walter.Web.FireWall.Filters.FireWallFilter>());

Inheritance Hierarchy


Object
  Walter.Web.FireWall.Configurations..::..HeaderConfig