Use MaxMind Geo data service or API keys to make the Walter.Web.IFireWall interface geographically aware allowing you to block requests for certain countries and enables you to render a different result based on the region or country the request came from. The Package adds functionality to NuGet package Walter.Web.Firewall services.AddFireWall(FireWallTrial.License, FireWallTrial.DomainKey , domainName: new Uri("https://www.your-domain.com", UriKind.Absolute) , options => { //your firewall settings }).UseGeography(directory:new DirectoryInfo("d:\\MaxMind")); This assumes that data files are in d:\MaxMind folder leave blank if you use App_Data and in your application configuration you can set blocking scope like this app.UseFireWall() .UseGeoBlockingMiddleware(options => { options.Block(new[]{GeoLocation.China ,GeoLocation.RussianFederation}); }); More information on how to use this Add-On is available in this manual https://www.asp-waf.com/download/ASP-WAF-FireWall-Getting-Started.pdf
$ dotnet add package Walter.Web.FireWall.Geo.MaxMindThis package allows you to protect your firewall using annotations and pre-specified rules. A full getting started document is available at www.asp-waf.com in form of a PDF, compiled help and simple instructions
The bellow sample shows how you integrate and enable the firewall in your project and use MaxMind for Geography. You can get free as well as paid geo data from https://www.maxmind.com these samples assume GeoLite2-Country.mmdb and GeoLite2-City.mmdb are available in a directory called D:\MaxMind and are shared by several web applications. If no path is provided App_Data is assumed.
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);
}).UseGeography(new System.IO.DirectoryInfo("D:\\MaxMind"));
The firewall is fully configurable and has quite a few options that allow you to protect against fishing, scrubbing, cross-site attach and much more.
There are a ton of configuration options available using the many annotations
namespace MyProject.Controllers
{
using Walter.Web.FireWall;
using Walter.Web.FireWall.Annotations;
using Walter.BOM.Geo;
[Geo(blockLocation: GeoLocation.AFRICA | GeoLocation.LATIN_AMERICA | GeoLocation.Netherlands)]
[Users(users: UserTypes.IsHuman | UserTypes.IsSearchEngine)]
[BlockDuration(duration: 60, sliding: true, doubleDurationPerIncedent: true)]
public sealed class MembersController : Controller
{
private readonly ILogger<MembersController> _logger;
private readonly IPageRequest _page;
public HomeController(ILogger<MembersController> logger,IPageRequest page)
{
_logger = logger;
_page=page;
}
public IActionResult Index()
{
return View();
}
[Ignore]
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
//the page field will contain all the errors the user ran into
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
}
}
This is just a small set of options of what's possible for the MaxMind package