Пример #1
0
            public async Task OnResourceExecutionAsync(ResourceExecutingContext context, ResourceExecutionDelegate next)
            {
                if (!_securitySettings.EnableHoneypotProtection)
                {
                    await next();

                    return;
                }

                var isBot = _honeypotProtector.IsBot();

                if (!isBot)
                {
                    await next();

                    return;
                }
                else
                {
                    _logger.Warn("Honeypot detected a bot and rejected the request.");

                    var redirectUrl = _webHelper.GetCurrentPageUrl(true);
                    context.Result = new RedirectResult(redirectUrl);
                }
            }
Пример #2
0
            public async Task OnResourceExecutionAsync(ResourceExecutingContext context, ResourceExecutionDelegate next)
            {
                // TODO: (mc) (core) Broken when setting is turned off :-/
                // RE: Could you try again please?
                if (!_securitySettings.EnableHoneypotProtection)
                {
                    await next();

                    return;
                }

                var isBot = _honeypotProtector.IsBot();

                if (!isBot)
                {
                    await next();

                    return;
                }
                else
                {
                    _logger.Warn("Honeypot detected a bot and rejected the request.");

                    var redirectUrl = _webHelper.GetCurrentPageUrl(true);
                    context.Result = new RedirectResult(redirectUrl);
                }
            }
Пример #3
0
            public void OnAuthorization(AuthorizationFilterContext context)
            {
                if (!_securitySettings.EnableHoneypotProtection)
                {
                    return;
                }

                var isBot = _honeypotProtector.IsBot();

                if (!isBot)
                {
                    return;
                }

                _logger.Warn("Honeypot detected a bot and rejected the request.");

                var redirectUrl = _webHelper.GetCurrentPageUrl(true);

                context.Result = new RedirectResult(redirectUrl);
            }