FailedLoginAttemptNotification

final class \TYPO3\CMS\Backend\EventListener\FailedLoginAttemptNotification

Uses
LogDataTrait

Sends out an email for failed logins in TYPO3 Backend when a certain threshold of failed logins during a certain timeframe has happened.

Relevant settings: $GLOBALS['TYPO3_CONF_VARS']['BE']['warning_email_addr']

Table of Contents

Methods

__construct()  : mixed
__invoke()  : void
Sends a warning email if there has been a certain amount of failed logins during a period.
formatLogDetails()  : string
Replaces a string with placeholders (%s or {myPlaceholder}) with its substitutes.
formatLogDetailsStatic()  : string
Static version for ViewHelpers etc.
unserializeLogData()  : array|null
Useful for handling old serialized data, which might have been migrated to JSON encoded properties already.

Methods

__construct()

public __construct(TemplatedEmailFactory $templatedEmailFactory, MailerInterface $mailer, ConnectionPool $connectionPool[, string|null $notificationRecipientEmailAddress = null ][, int $warningPeriod = 3600 ][, int $failedLoginAttemptsThreshold = 3 ]) : mixed

Parameters

$templatedEmailFactory : TemplatedEmailFactory
$mailer : MailerInterface
$connectionPool : ConnectionPool
$notificationRecipientEmailAddress : string|null = null

The receiver of the notification

$warningPeriod : int = 3600

Time span (in seconds) within the number of failed logins are collected. Number of sections back in time to check. This is a kind of limit for how many failures an hour.

$failedLoginAttemptsThreshold : int = 3

The maximum accepted number of warnings before an email to $notificationRecipientEmailAddress is sent

__invoke()

Sends a warning email if there has been a certain amount of failed logins during a period.

public __invoke(LoginAttemptFailedEvent|MfaVerificationFailedEvent $event) : void

If a login fails, this function is called. It will look up the sys_log to see if there have been more than $failedLoginAttemptsThreshold failed logins the last X seconds (default 3600, see $warningPeriod). If so, an email with a warning is sent. This also includes failed multi-factor authentication failures.

Parameters

$event : LoginAttemptFailedEvent|MfaVerificationFailedEvent

Attributes

#[AsEventListener]
$identifier: 'typo3/cms-backend/failed-login-attempt-notification'
$event: LoginAttemptFailedEvent::class
#[AsEventListener]
$identifier: 'typo3/cms-backend/failed-mfa-verification-notification'
$event: MfaVerificationFailedEvent::class

formatLogDetails()

Replaces a string with placeholders (%s or {myPlaceholder}) with its substitutes.

protected formatLogDetails(string $detailString, mixed $substitutes) : string

Parameters

$detailString : string
$substitutes : mixed

Return values

string

formatLogDetailsStatic()

Static version for ViewHelpers etc.

protected static formatLogDetailsStatic(string $detailString, array $substitutes) : string

Replaces a string with placeholders (%s or {myPlaceholder}) with its substitutes.

Parameters

$detailString : string
$substitutes : array

Return values

string

unserializeLogData()

Useful for handling old serialized data, which might have been migrated to JSON encoded properties already.

protected unserializeLogData(mixed $logData) : array|null

Parameters

$logData : mixed

Return values

array|null
On this page