Skip to content
GitLab
Menu
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
559e3273
Commit
559e3273
authored
Dec 22, 2020
by
Dominik Hebeler
Browse files
added logging to fail2ban server
parent
2ba80f66
Changes
3
Hide whitespace changes
Inline
Side-by-side
app/Http/Controllers/HumanVerification.php
View file @
559e3273
...
...
@@ -90,6 +90,30 @@ class HumanVerification extends Controller
}
public
static
function
logCaptcha
(
Request
$request
){
$fail2banEnabled
=
config
(
"metager.metager.fail2ban_enabled"
);
if
(
empty
(
$fail2banEnabled
)
||
!
$fail2banEnabled
||
!
env
(
"fail2banurl"
,
false
)
||
!
env
(
"fail2banuser"
)
||
!
env
(
"fail2banpassword"
)){
return
;
}
// Submit fetch job to worker
$mission
=
[
"resulthash"
=>
"captcha"
,
"url"
=>
env
(
"fail2banurl"
)
.
"/captcha/"
,
"useragent"
=>
"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:81.0) Gecko/20100101 Firefox/81.0"
,
"username"
=>
env
(
"fail2banuser"
),
"password"
=>
env
(
"fail2banpassword"
),
"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
(
'mm'
))
{
...
...
app/Http/Middleware/HumanVerification.php
View file @
559e3273
...
...
@@ -46,7 +46,7 @@ class HumanVerification
* If someone that uses a bot finds this out we
* might have to change it at some point.
*/
if
(
$request
->
filled
(
'appversion'
)
||
!
env
(
'BOT_PROTECTION'
,
false
)
||
app
(
'App\Models\Key'
)
->
getStatus
())
{
if
(
!
env
(
'BOT_PROTECTION'
,
false
)
||
app
(
'App\Models\Key'
)
->
getStatus
())
{
$update
=
false
;
return
$next
(
$request
);
}
...
...
@@ -103,6 +103,7 @@ class HumanVerification
# If the user is locked we will force a Captcha validation
if
(
$user
[
"locked"
])
{
\
App\Http\Controllers\HumanVerification
::
logCaptcha
(
$request
);
return
redirect
()
->
route
(
'captcha'
,
[
"id"
=>
$id
,
"uid"
=>
$uid
,
"url"
=>
url
()
->
full
()]);
}
...
...
config/metager/metager.php
View file @
559e3273
<?php
return
[
"browserverification_enabled"
=>
tru
e
,
"browserverification_enabled"
=>
fals
e
,
"browserverification_whitelist"
=>
[
"w3m\/"
,
],
"fail2ban_enabled"
=>
true
,
];
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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