TagHelpers Firewall Geo Block - ASP-WAF/FireWall GitHub Wiki
Firewall Geographical Filtering
For this tag helper to work you will have had to make the firewall geo-aware. You have 2 ways to do this, we will go over them there.
Option 1: Use a Walter.Web.FireWall.Geo.* NuGet package
The firewall framework contains 2 Nuget packages that will inform each request of the geography where a request was initiated from. 1 Walter.Web.FireWall.Geo.Native Uses the MaxMind framework to resolve the geographical location ((more information) 2 **Walter.Web.FireWall.Geo.MaxMind ** Uses the DNS service of the firewall to resolve the geographical location ((more information)
The sample below demonstrates what such a service registration would look like
//use memory cache to remember discovered locations
services.AddMemoryCache();
services.AddFireWall(FireWallTrail.License, FireWallTrail.DomainKey
, domainName: new Uri("https://www.your-domain.com", UriKind.Absolute)
, options =>
{
options.Cypher.ApplicationPassword = "123456$even";
options.ApplicationName = "Name as used for reporting";
options.ApplicationTag = "ITIL Tag";
options.Rules.BlockRequest.BlockDuration.SlideExpiration = true;
options.Rules.BlockRequest.BlockDuration.Expires = TimeSpan.FromSeconds(10);
//used by JavaScript in the browser and the Walter.Web.FireWall.DefaultEndpoints NuGet package
options.WebServices.UserEndpointJavaScript = new Uri(Walter.Web.FireWall.DefaultEndpoints.DefaultLinks.UserEndpointJavaScript, UriKind.Relative);
options.WebServices.IsUserApiUrl = new Uri(Walter.Web.FireWall.DefaultEndpoints.DefaultLinks.IsUserEndpoint, UriKind.Relative);
options.WebServices.RegisterLinksApiUrl = new Uri(Walter.Web.FireWall.DefaultEndpoints.DefaultLinks.SiteMapEndPoint, UriKind.Relative);
options.WebServices.BeaconApiUrl = new Uri(Walter.Web.FireWall.DefaultEndpoints.DefaultLinks.BeaconPoint, UriKind.Relative);
options.WebServices.CSPReportUrl = new Uri(Walter.Web.FireWall.DefaultEndpoints.DefaultLinks.CSPViolation, UriKind.Relative);
//Geography parameters change based on the NuGet package used
}).UseGeography();
//protect each request
services.AddMvc(options =>
options.Filters.Add<Walter.Web.FireWall.Filters.FireWallFilter>()
);
//protect each MVC controller
services.AddMvc(options =>
options.Filters.Add<Walter.Web.FireWall.Filters.FireWallFilter>()
);
Option 2: Assign the region manually using your own framework
For you to use your own method to resolve geographical locations you will need to implement the IGeoFactory and inject that interface in the IServiceCollection when starting your application.