change regex for fail2ban

This commit is contained in:
Philipp Holzer 2019-01-07 21:08:09 +01:00 committed by Hypolite Petovan
parent aa15c0e094
commit b5afd2a21d
3 changed files with 5 additions and 7 deletions

View File

@ -56,7 +56,7 @@ In */etc/fail2ban/jail.local* create a section for Friendica:
And create a filter definition in */etc/fail2ban/filter.d/friendica.conf*: And create a filter definition in */etc/fail2ban/filter.d/friendica.conf*:
[Definition] [Definition]
failregex = ^.*Login\.php.*failed login attempt.*from IP <HOST>.*$ failregex = ^.*authenticate\: failed login attempt.*\"ip\"\:\"<HOST>\".*$
ignoreregex = ignoreregex =
Additionally you have to define the number of failed logins before the ban should be activated. Additionally you have to define the number of failed logins before the ban should be activated.

View File

@ -323,21 +323,19 @@ class Logger extends BaseObject
* @brief Logs the given message at the given log level * @brief Logs the given message at the given log level
* *
* @param string $msg * @param string $msg
* @param int $level * @param string $level
* *
* @throws \Exception * @throws \Exception
* @deprecated since 2019.03 Use Logger::debug() Logger::info() , ... instead * @deprecated since 2019.03 Use Logger::debug() Logger::info() , ... instead
*/ */
public static function log($msg, $level = 3) public static function log($msg, $level = LogLevel::INFO)
{ {
if (!isset(self::$logger)) { if (!isset(self::$logger)) {
return; return;
} }
$loglevel = self::mapLegacyDebugLevel($level);
$stamp1 = microtime(true); $stamp1 = microtime(true);
self::$logger->log($loglevel, $msg); self::$logger->log($level, $msg);
self::getApp()->saveTimestamp($stamp1, "file"); self::getApp()->saveTimestamp($stamp1, "file");
} }

View File

@ -148,7 +148,7 @@ class Login extends BaseModule
); );
} }
} catch (Exception $e) { } catch (Exception $e) {
Logger::notice('authenticate: failed login attempt', ['username' => Strings::escapeTags($username), 'ip' => $_SERVER['REMOTE_ADDR']]); Logger::notice('authenticate: failed login attempt', ['action' => 'login', 'username' => Strings::escapeTags($username), 'ip' => $_SERVER['REMOTE_ADDR']]);
info('Login failed. Please check your credentials.' . EOL); info('Login failed. Please check your credentials.' . EOL);
$a->internalRedirect(); $a->internalRedirect();
} }