Commit 1f9c3b6e authored by Patrick Müller's avatar Patrick Müller

feat: Watch failed login attempts (quiqqer/watcher)

parent 130c6634
......@@ -697,7 +697,7 @@ class Manager
} catch (QUI\Users\Exception $Exception) {
$Exception->setAttribute('reason', self::AUTH_ERROR_AUTH_ERROR);
QUI::getEvents()->fireEvent('userLoginError', array($userId, $Exception));
QUI::getEvents()->fireEvent('userLoginError', array($userId, $Exception, $authenticator));
throw $Exception;
} catch (\Exception $Exception) {
......
<?php
namespace QUI;
use QUI;
/**
* Class Watch
*
* Set quiqqer/watcher messages
*/
class Watch
{
/**
* Write failed login attempts to watcher log
*
* @param string $event
* @param array $params
* @return string
*/
public static function authenticatorLoginError($event, $params)
{
$userId = $params[0];
$authenticator = '-';
if (!empty($params[2])) {
$authenticator = $params[2];
}
$username = QUI::getLocale()->get('quiqqer/system', 'watch.unknown_user');
try {
$User = QUI::getUsers()->get($userId);
$username = $User->getUsername();
} catch (\Exception $Exception) {
// nothing
}
return QUI::getLocale()->get(
'quiqqer/system',
'watch.authenticatorLoginError',
array(
'userId' => $userId ?: '-',
'username' => $username,
'authenticator' => $authenticator,
'ipAddress' => $_SERVER['REMOTE_ADDR'],
'userAgent' => empty($_SERVER['HTTP_USER_AGENT']) ? '-' : $_SERVER['HTTP_USER_AGENT']
)
);
}
}
......@@ -6183,7 +6183,17 @@ Folgende Zeichen sind erlaubt: 0-9 a-z A-Z _ -</p>]]></de>
</groups>
<groups name="quiqqer/system" datatype="php">
<!-- Control: Users/Controls/Login -->
<!-- Class: QUI\Watch -->
<locale name="watch.unknown_user">
<de><![CDATA[Unbekannter Benutzer]]></de>
<en><![CDATA[Unknown user]]></en>
</locale>
<locale name="watch.authenticatorLoginError">
<de><![CDATA[Gescheiterter Login-Versuch: "[username]" (#[userId]) | Authenticator: "[authenticator]" | IP-Adresse: [ipAddress] | User Agent: "[userAgent]"]]></de>
<en><![CDATA[Failed login attempt: "[username]" (#[userId]) | Authenticator: "[authenticator]" | IP address: [ipAddress] | User Agent: "[userAgent]"]]></en>
</locale>
<!-- Control: QUI\Users\Controls\Login -->
<locale name="controls.users.auth.login.or">
<de><![CDATA[oder]]></de>
<en><![CDATA[or]]></en>
......
<quiqqer>
<watch event="onUserLoginError" exec="\QUI\Watch::authenticatorLoginError" />
</quiqqer>
\ No newline at end of file
Markdown is supported
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