mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-07 00:17:03 +03:00
Bugfix: don't log admin auth fail attempts twice
This commit is contained in:
parent
cb15085dc6
commit
182aee6bb8
3 changed files with 10 additions and 11 deletions
|
|
@ -626,19 +626,18 @@ class Actions
|
||||||
return $this->oLoggerAuth;
|
return $this->oLoggerAuth;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function LoggerAuthHelper(?Model\Account $oAccount = null, array $aAdditionalParams = array()): void
|
protected function LoggerAuthHelper(?Model\Account $oAccount = null, array $aAdditionalParams = array(), bool $admin = false): void
|
||||||
{
|
{
|
||||||
$sLine = $this->oConfig->Get('logs', 'auth_logging_format', '');
|
$sLine = $this->oConfig->Get('logs', 'auth_logging_format', '');
|
||||||
if (!empty($sLine)) {
|
if (!empty($sLine)) {
|
||||||
$this->LoggerAuth()->Write($this->compileLogParams($sLine, $oAccount, false, $aAdditionalParams));
|
$this->LoggerAuth()->Write($this->compileLogParams($sLine, $oAccount, false, $aAdditionalParams));
|
||||||
}
|
}
|
||||||
$this->SysLogAuth($this->compileLogParams('Auth failed: ip={request:ip} user={imap:login}', $oAccount, false, $aAdditionalParams));
|
if (($this->oConfig->Get('logs', 'auth_logging', false) || $this->oConfig->Get('logs', 'auth_syslog', false))
|
||||||
}
|
&& \openlog('snappymail', 0, \LOG_AUTHPRIV)) {
|
||||||
|
\syslog(\LOG_ERR, $this->compileLogParams(
|
||||||
protected function SysLogAuth(string $message): void
|
$admin ? 'Admin Auth failed: ip={request:ip} user={user:login}' : 'Auth failed: ip={request:ip} user={imap:login}',
|
||||||
{
|
$oAccount, false, $aAdditionalParams
|
||||||
if ($this->oConfig->Get('logs', 'auth_logging', false) && \openlog('snappymail', 0, \LOG_AUTHPRIV)) {
|
));
|
||||||
\syslog(\LOG_ERR, $message);
|
|
||||||
\closelog();
|
\closelog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -212,8 +212,7 @@ trait Admin
|
||||||
!$this->Config()->ValidatePassword($sPassword)
|
!$this->Config()->ValidatePassword($sPassword)
|
||||||
|| ($totp && !\SnappyMail\TOTP::Verify($totp, $this->GetActionParam('TOTP', ''))))
|
|| ($totp && !\SnappyMail\TOTP::Verify($totp, $this->GetActionParam('TOTP', ''))))
|
||||||
{
|
{
|
||||||
$this->SysLogAuth($this->compileLogParams('Admin Auth failed: ip={request:ip} user={user:login}'));
|
$this->LoggerAuthHelper(null, $this->getAdditionalLogParamsByUserLogin($sLogin, true), true);
|
||||||
$this->LoggerAuthHelper(null, $this->getAdditionalLogParamsByUserLogin($sLogin, true));
|
|
||||||
$this->loginErrorDelay();
|
$this->loginErrorDelay();
|
||||||
throw new ClientException(Notifications::AuthError);
|
throw new ClientException(Notifications::AuthError);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -299,7 +299,8 @@ Examples:
|
||||||
|
|
||||||
'auth_logging' => array(false, 'Enable auth logging in a separate file (for fail2ban)'),
|
'auth_logging' => array(false, 'Enable auth logging in a separate file (for fail2ban)'),
|
||||||
'auth_logging_filename' => array('fail2ban/auth-{date:Y-m-d}.txt'),
|
'auth_logging_filename' => array('fail2ban/auth-{date:Y-m-d}.txt'),
|
||||||
'auth_logging_format' => array('[{date:Y-m-d H:i:s}] Auth failed: ip={request:ip} user={imap:login} host={imap:host} port={imap:port}')
|
'auth_logging_format' => array('[{date:Y-m-d H:i:s}] Auth failed: ip={request:ip} user={imap:login} host={imap:host} port={imap:port}'),
|
||||||
|
'auth_syslog' => array(false, 'Enable auth logging to syslog for fail2ban')
|
||||||
),
|
),
|
||||||
|
|
||||||
'debug' => array(
|
'debug' => array(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue