Commit 517b5bf1 authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

removed fail2ban mostly

parent 8a85dea9
......@@ -170,30 +170,6 @@ class HumanVerification extends Controller
}
}
public static function logCaptcha(Request $request)
{
$fail2banEnabled = config("metager.metager.fail2ban.enabled");
if (empty($fail2banEnabled) || !$fail2banEnabled || !config("metager.metager.fail2ban.url") || !config("metager.metager.fail2ban.user") || !config("metager.metager.fail2ban.password")) {
return;
}
// Submit fetch job to worker
$mission = [
"resulthash" => "captcha",
"url" => config("metager.metager.fail2ban.url") . "/captcha/",
"useragent" => "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:81.0) Gecko/20100101 Firefox/81.0",
"username" => config("metager.metager.fail2ban.user"),
"password" => config("metager.metager.fail2ban.password"),
"headers" => [
"ip" => $request->ip()
],
"cacheDuration" => 0,
"name" => "Captcha",
];
$mission = json_encode($mission);
Redis::rpush(\App\MetaGer::FETCHQUEUE_KEY, $mission);
}
public static function remove(Request $request)
{
if (!$request->has('hv') || !Cache::has($request->input("hv"))) {
......
......@@ -82,7 +82,6 @@ class HumanVerification
# If the user is locked we will force a Captcha validation
if ($user->isLocked()) {
$user->saveUser();
\App\Http\Controllers\HumanVerification::logCaptcha($request);
\app()->make(QueryTimer::class)->observeEnd(self::class);
$this->logCaptcha($request, $user);
echo redirect()->route('captcha_show', ["url" => URL::full(), "key" => $user->key]); // TODO uncomment
......
......@@ -39,7 +39,6 @@ class Spam
$browser->setUserAgent($_SERVER["AGENT"]);
if ($browser->browser() === "Chrome" && $browser->version($browser->browser()) === "91.0.4472.77") {
$this->logFail2Ban($request->ip());
abort(404);
}
// ToDo Remove Log
......@@ -69,28 +68,4 @@ class Spam
return $next($request);
}
private function logFail2Ban($ip)
{
$fail2banEnabled = config("metager.metager.fail2ban.enabled");
if (empty($fail2banEnabled) || !$fail2banEnabled || !config("metager.metager.fail2ban.url") || !config("metager.metager.fail2ban.user") || !config("metager.metager.fail2ban.password")) {
return;
}
// Submit fetch job to worker
$mission = [
"resulthash" => "browserverification.ban",
"url" => config("metager.metager.fail2ban.url") . "/spam/",
"useragent" => "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:81.0) Gecko/20100101 Firefox/81.0",
"username" => config("metager.metager.fail2ban.user"),
"password" => config("metager.metager.fail2ban.password"),
"headers" => [
"ip" => $ip
],
"cacheDuration" => 0,
"name" => "Captcha",
];
$mission = json_encode($mission);
Redis::rpush(\App\MetaGer::FETCHQUEUE_KEY, $mission);
}
}
}
\ No newline at end of file
<?php
namespace App\Listeners;
use Illuminate\Auth\Events\Failed;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Support\Facades\Redis;
use Illuminate\Support\Facades\Request;
class LogFailedAuthenticationAttempt
{
/**
* Create the event listener.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Handle the event.
*
* @param Failed $event
* @return void
*/
public function handle(Failed $event)
{
// Authentication failed Let's log the user
$fail2banEnabled = config("metager.metager.fail2ban.enabled");
if(empty($fail2banEnabled) || !$fail2banEnabled || !config("metager.metager.fail2ban.url") || !config("metager.metager.fail2ban.user") || !config("metager.metager.fail2ban.password")){
return;
}
// Submit fetch job to worker
$mission = [
"resulthash" => "captcha",
"url" => config("metager.metager.fail2ban.url") . "/mgadmin/",
"useragent" => "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:81.0) Gecko/20100101 Firefox/81.0",
"username" => config("metager.metager.fail2ban.user"),
"password" => config("metager.metager.fail2ban.password"),
"headers" => [
"ip" => Request::ip()
],
"cacheDuration" => 0,
"name" => "Captcha",
];
$mission = json_encode($mission);
Redis::rpush(\App\MetaGer::FETCHQUEUE_KEY, $mission);
}
}
......@@ -12,11 +12,7 @@ class EventServiceProvider extends ServiceProvider
*
* @var array
*/
protected $listen = [
'Illuminate\Auth\Events\Failed' => [
'App\Listeners\LogFailedAuthenticationAttempt',
],
];
protected $listen = [];
/**
* Register any events for your application.
......@@ -39,4 +35,4 @@ class EventServiceProvider extends ServiceProvider
{
return false;
}
}
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment