Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
open-source
MetaGer
Commits
517b5bf1
Commit
517b5bf1
authored
Jan 20, 2023
by
Dominik Hebeler
Browse files
removed fail2ban mostly
parent
8a85dea9
Changes
5
Hide whitespace changes
Inline
Side-by-side
metager/app/Http/Controllers/HumanVerification.php
View file @
517b5bf1
...
...
@@ -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"
)))
{
...
...
metager/app/Http/Middleware/HumanVerification.php
View file @
517b5bf1
...
...
@@ -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
...
...
metager/app/Http/Middleware/Spam.php
View file @
517b5bf1
...
...
@@ -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
metager/app/Listeners/LogFailedAuthenticationAttempt.php
deleted
100644 → 0
View file @
8a85dea9
<?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
);
}
}
metager/app/Providers/EventServiceProvider.php
View file @
517b5bf1
...
...
@@ -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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment