Walter.BOM Namespace
Walter.Web.FireWall Namespace
ASP-WAF Web application firewall for .Net 6, .Net 5, .Net Standard 2.1 and .Net Core 3.x

IPageRequest Interface

Interface IPageRequest contains the meta data in as the firewall managed this page and it's access to it, a custom implementation of this Interface will be rejected by the firewall

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

Syntax


public interface IPageRequest : IInstrumented

Remarks


A instance of IPageRequest is contract that contains scoped data storage populated with data related to the requesting user and is used when delivering a given page and is valid only for a given page request and is the class that is passed between the web application, the firewall, and the guard engines and is ultimately passed to storage and reporting interfaces.

Examples


The bellow example shows how the IPageRequest can be used to access the requester related data as well as the firewall
C#
namespace MyWeb.Controllers
{
    using Walter.Web.FireWall;
    using Walter.Web.FireWall.Annotations;
    using Walter.Web.FireWall.Filters;
    using Walter.Web.FireWall.Geo;
    using Walter.Web.FireWall.RuleEngine.Rules;

    [BlockDuration(seconds: 60, sliding: true, doubleDurationPerIncident: true)]
    public class HomeController : Controller
    {
        private readonly IPageRequest _page;
        private ILatLongRepository _latLongRepository;

        public HomeController(IPageRequest page, ILatLongRepository latLongRepository)
        {
            _page = page;
            _latLongRepository = latLongRepository;
        }


        [GeoIgnore(maxRequest: 5)]
        [Ignore(skip: FireWallGuardActions.RejectPenetrationAttempts
                     | FireWallGuardActions.RejectRepeatViolations
                     | FireWallGuardActions.RejectWrongUserType
            , skipCount: 5)]
        public IActionResult Blocked(BlockingReason id)
        {


            if (_page.User.AsFirewallUser().UserType.HasFlag(UserTypes.IsMalicious))
            {
                return View("_Malicious", id);
            }
            return View(id);
        }

        [Minify]
        [HttpGet]
        [Users(blocked: UserTypes.IsMalicious
                 , allow: UserTypes.IsHuman | UserTypes.IsSearchEngine | UserTypes.NotDiscovered
                 , redirectToController: "home", redirectAction: "blocked", id: (int)BlockingReason.WrongConsumerType)]
        public async Task<IActionResult> Index()
        {

            if (!_page.User.TryReadCookie("Telephone", out var phone))
            {
                phone = "001.123.567.89 ext 123";
            }

            await _page.User.WriteCookieAsync("Telephone", phone, TimeSpan.FromSeconds(60)).ConfigureAwait(false);

            //_fireWall.SendEmail(EMailRoles.ProductUpdates, "test mail", "this is a test email", false);var model = new IndexModel();
            model.UserQuery = new Query() { IPAddress = _page.IPAddress.ToString() };
            model.UserResult = await _page.FireWall.WhoisAsync(_page).ConfigureAwait(false);
            model.Geography = _latLongRepository.QueryMapLocation(_page.IPAddress);
            return View(model);
        }
    }
}

Thread Safety


Static members of this type are safe for multi-threaded operations. Instance members of this type are safe for multi-threaded operations.