From 89e96d8333a220c520c3a4bd6f0cee008627a07f Mon Sep 17 00:00:00 2001 From: ThreeCO <42574949+ThreeCO@users.noreply.github.com> Date: Thu, 31 Dec 2020 05:45:56 +0100 Subject: [PATCH] Add IP address to authentication error logs --- app/Subscriber/AuthSubscriber.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/Subscriber/AuthSubscriber.php b/app/Subscriber/AuthSubscriber.php index 3f6ad05a5..2305a6aa1 100644 --- a/app/Subscriber/AuthSubscriber.php +++ b/app/Subscriber/AuthSubscriber.php @@ -95,10 +95,11 @@ class AuthSubscriber extends BaseSubscriber implements EventSubscriberInterface { $this->logger->debug('Subscriber executed: '.__METHOD__); $username = $event->getUsername(); - + $ipAddress = $this->request->getIpAddress(); + if (! empty($username)) { // log login failure in web server log to allow fail2ban usage - error_log('Kanboard: user '.$username.' authentication failure'); + error_log('Kanboard: user '.$username.' authentication failure with IP address: '.$ipAddress); $this->userLockingModel->incrementFailedLogin($username); if ($this->userLockingModel->getFailedLogin($username) > BRUTEFORCE_LOCKDOWN) { @@ -107,7 +108,7 @@ class AuthSubscriber extends BaseSubscriber implements EventSubscriberInterface } else { // log login failure in web server log to allow fail2ban usage - error_log('Kanboard: user Unknown authentication failure'); + error_log('Kanboard: user Unknown authentication failure with IP address: '.$ipAddress); } } }