class LoginAttemptService (View source)

Constants

STAGE_PASSWORD

Kept as string constants for callers; {LoginAttemptStage} owns the vocabulary.

STAGE_MFA

Methods

__construct(PDO $connection, ConfigurationManager|null $configManager = null)

No description

void
recordAttempt(string $username, string $ipAddress, bool $successful, string $attemptType = self::STAGE_PASSWORD, int|null $userId = null)

No description

bool
isIpBlacklisted(string $ipAddress)

Whether the address is on the configured lockout blacklist.

bool
isAccountLocked(string $username, string $ipAddress, string $attemptType = self::STAGE_PASSWORD, int|null $userId = null)

No description

bool
isIpInList(string $ipAddress, array $ipList)

Check if an IP address is in the given list.

Details

__construct(PDO $connection, ConfigurationManager|null $configManager = null)

No description

Parameters

PDO $connection
ConfigurationManager|null $configManager

void recordAttempt(string $username, string $ipAddress, bool $successful, string $attemptType = self::STAGE_PASSWORD, int|null $userId = null)

No description

Parameters

string $username
string $ipAddress
bool $successful
string $attemptType

Lockout stage identifier; defaults to "password" so existing callers (SQL/LDAP/DDNS) are unchanged. Pass STAGE_MFA from the MFA verify path to keep second-factor failures from polluting the first-factor counter.

int|null $userId

Account the attempt belongs to. Pass it whenever the caller already knows it, rather than relying on the username to resolve: the MFA stage verifies against the pending user id, and keying the counter on a separately held session name would let the two drift.

Return Value

void

bool isIpBlacklisted(string $ipAddress)

Whether the address is on the configured lockout blacklist.

Parameters

string $ipAddress

Return Value

bool

bool isAccountLocked(string $username, string $ipAddress, string $attemptType = self::STAGE_PASSWORD, int|null $userId = null)

No description

Parameters

string $username
string $ipAddress
string $attemptType
int|null $userId

Return Value

bool

bool isIpInList(string $ipAddress, array $ipList)

Check if an IP address is in the given list.

Supports individual IPs, CIDRs (e.g., 192.168.1.0/24), and wildcards (e.g., 192.168.1.*)

Parameters

string $ipAddress

The IP address to check

array $ipList

List of IPs/CIDRs/wildcards to match against

Return Value

bool

True if the IP is in the list