Heratio Framework API Reference

LoginSecurityService
in package

Login security service — brute force protection.

Tracks failed login attempts and enforces account lockout after exceeding the threshold. Uses the login_attempt table to record attempts by identifier (email/username) and IP address.

Default policy: 5 failed attempts within 15 minutes = 15-minute lockout.

Table of Contents

Methods

cleanup()  : void
Cleanup old login attempt records (older than 24 hours).
clearFailures()  : void
Clear failed attempt records for an identifier (after successful login).
isLockedOut()  : bool
Check if a login identifier is currently locked out.
lockoutRemaining()  : int
Get seconds until lockout expires.
recordAttempt()  : void
Record a login attempt.
remainingAttempts()  : int
Get the number of remaining attempts before lockout.

Methods

cleanup()

Cleanup old login attempt records (older than 24 hours).

public static cleanup() : void

Call periodically via cron to prevent table growth.

clearFailures()

Clear failed attempt records for an identifier (after successful login).

public static clearFailures(string $identifier) : void
Parameters
$identifier : string

isLockedOut()

Check if a login identifier is currently locked out.

public static isLockedOut(string $identifier[, string $ipAddress = '' ]) : bool
Parameters
$identifier : string

Email or username

$ipAddress : string = ''

Client IP address

Return values
bool

True if locked out

lockoutRemaining()

Get seconds until lockout expires.

public static lockoutRemaining(string $identifier) : int
Parameters
$identifier : string

Email or username

Return values
int

Seconds until unlock, 0 if not locked

recordAttempt()

Record a login attempt.

public static recordAttempt(string $identifier, string $ipAddress, bool $success) : void
Parameters
$identifier : string

Email or username

$ipAddress : string

Client IP

$success : bool

Whether the attempt succeeded

remainingAttempts()

Get the number of remaining attempts before lockout.

public static remainingAttempts(string $identifier) : int
Parameters
$identifier : string

Email or username

Return values
int

Remaining attempts (0 = locked out)


        
On this page

Search results