RequestRateLimiter
in package
Atomic fixed-window limits shared by every replica using the same database.
Table of Contents
Constants
- BUCKET_EMAIL_TAKEN : mixed = 'members.email_taken'
- BUCKET_GITHUB_ISSUE : mixed = 'github.issue_submit'
- BUCKET_PIN : mixed = 'members.pin'
- BUCKET_PLATFORM_LOGIN_ACCOUNT : mixed = 'platform.login_account'
- BUCKET_PLATFORM_LOGIN_IP : mixed = 'platform.login_ip'
- BUCKET_PLATFORM_STEP_UP : mixed = 'platform.step_up'
- BUCKET_RESET_ACCOUNT : mixed = 'members.reset_account'
- BUCKET_RESET_COOLDOWN : mixed = 'members.reset_cooldown'
- BUCKET_RESET_IP : mixed = 'members.reset_ip'
- BUCKET_SEARCH_MEMBERS : mixed = 'members.search_members'
- LIMITS : mixed = [self::BUCKET_EMAIL_TAKEN => ['max' => 10, 'win...
Properties
- $clock : Closure
- $connection : Connection|null
Methods
- __construct() : mixed
- Use an explicit connection for tests or platform operations.
- attempt() : RateLimitResult
- Atomically reserve an attempt; database errors fail closed.
- releaseSuccessfulAttempt() : void
- Release one successful MFA reservation without forgiving earlier failures.
Constants
BUCKET_EMAIL_TAKEN
public
mixed
BUCKET_EMAIL_TAKEN
= 'members.email_taken'
BUCKET_GITHUB_ISSUE
public
mixed
BUCKET_GITHUB_ISSUE
= 'github.issue_submit'
BUCKET_PIN
public
mixed
BUCKET_PIN
= 'members.pin'
BUCKET_PLATFORM_LOGIN_ACCOUNT
public
mixed
BUCKET_PLATFORM_LOGIN_ACCOUNT
= 'platform.login_account'
BUCKET_PLATFORM_LOGIN_IP
public
mixed
BUCKET_PLATFORM_LOGIN_IP
= 'platform.login_ip'
BUCKET_PLATFORM_STEP_UP
public
mixed
BUCKET_PLATFORM_STEP_UP
= 'platform.step_up'
BUCKET_RESET_ACCOUNT
public
mixed
BUCKET_RESET_ACCOUNT
= 'members.reset_account'
BUCKET_RESET_COOLDOWN
public
mixed
BUCKET_RESET_COOLDOWN
= 'members.reset_cooldown'
BUCKET_RESET_IP
public
mixed
BUCKET_RESET_IP
= 'members.reset_ip'
BUCKET_SEARCH_MEMBERS
public
mixed
BUCKET_SEARCH_MEMBERS
= 'members.search_members'
LIMITS
private
mixed
LIMITS
= [self::BUCKET_EMAIL_TAKEN => ['max' => 10, 'window' => 900], self::BUCKET_SEARCH_MEMBERS => ['max' => 15, 'window' => 900], self::BUCKET_GITHUB_ISSUE => ['max' => 5, 'window' => 3600], self::BUCKET_RESET_IP => ['max' => 10, 'window' => 900], self::BUCKET_RESET_ACCOUNT => ['max' => 3, 'window' => 3600], self::BUCKET_RESET_COOLDOWN => ['max' => 1, 'window' => 300], self::BUCKET_PIN => ['max' => 5, 'window' => 300], self::BUCKET_PLATFORM_LOGIN_IP => ['max' => 20, 'window' => 900], self::BUCKET_PLATFORM_LOGIN_ACCOUNT => ['max' => 5, 'window' => 900], self::BUCKET_PLATFORM_STEP_UP => ['max' => 5, 'window' => 900]]
Properties
$clock read-only
private
Closure
$clock
$connection read-only
private
Connection|null
$connection
= null
Methods
__construct()
Use an explicit connection for tests or platform operations.
public
__construct([Connection|null $connection = null ][, callable|null $clock = null ]) : mixed
Parameters
- $connection : Connection|null = null
- $clock : callable|null = null
attempt()
Atomically reserve an attempt; database errors fail closed.
public
attempt(string $bucket, string $clientKey) : RateLimitResult
Parameters
- $bucket : string
- $clientKey : string
Return values
RateLimitResultreleaseSuccessfulAttempt()
Release one successful MFA reservation without forgiving earlier failures.
public
releaseSuccessfulAttempt(RateLimitResult $attempt) : void
Parameters
- $attempt : RateLimitResult