mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-08-26 04:05:57 +00:00
Log failed accesses
This commit is contained in:
parent
33ef1cd4fa
commit
12a9a45747
@ -101,6 +101,9 @@ class LoginController extends Controller
|
||||
$this->hasTooManyLoginAttempts($request)) {
|
||||
$this->fireLockoutEvent($request);
|
||||
|
||||
// Also log some error message
|
||||
$this->logFailedAccess($request);
|
||||
|
||||
return $this->sendLockoutResponse($request);
|
||||
}
|
||||
|
||||
@ -117,6 +120,9 @@ class LoginController extends Controller
|
||||
// user surpasses their maximum number of attempts they will get locked out.
|
||||
$this->incrementLoginAttempts($request);
|
||||
|
||||
// Also log some error message
|
||||
$this->logFailedAccess($request);
|
||||
|
||||
return $this->sendFailedLoginResponse($request);
|
||||
}
|
||||
|
||||
@ -162,4 +168,16 @@ class LoginController extends Controller
|
||||
return redirect('/login');
|
||||
}
|
||||
|
||||
/**
|
||||
* Log failed accesses, matching the default fail2ban nginx/apache auth rules.
|
||||
*/
|
||||
protected function logFailedAccess(Request $request)
|
||||
{
|
||||
if (isset($_SERVER['SERVER_SOFTWARE']) && preg_match('/nginx/i', $_SERVER['SERVER_SOFTWARE'])) {
|
||||
error_log('user "' . $request->get($this->username()) . '" was not found in "BookStack"', 4);
|
||||
} else {
|
||||
error_log('user "' . $request->get($this->username()) . '" authentication failure for "BookStack"', 4);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user