CreaCaptcha

RateLimiter
in package

Counts requests per client IP in a fixed time window and blocks with HTTP 429 once the configured limit is exceeded. See the module-4 design spec §6.

Table of Contents

Methods

run()  : void
Runs the rate limiter for the current request. Registered on `init` at priority 0. Terminates the request with 429 once the limit is exceeded.
context()  : array{ip: string, path: string, method: string, script: string, action: string, is_ajax: bool}
Builds the request context array.
is_challenge_endpoint()  : bool
Whether the request points at the plugin's own challenge endpoint.
should_count()  : bool
Whether the current request counts toward the rate limit.

Methods

run()

Runs the rate limiter for the current request. Registered on `init` at priority 0. Terminates the request with 429 once the limit is exceeded.

public run() : void

context()

Builds the request context array.

private context(string $ip) : array{ip: string, path: string, method: string, script: string, action: string, is_ajax: bool}
Parameters
$ip : string
Return values
array{ip: string, path: string, method: string, script: string, action: string, is_ajax: bool}

is_challenge_endpoint()

Whether the request points at the plugin's own challenge endpoint.

private is_challenge_endpoint(string $path) : bool
Parameters
$path : string
Return values
bool

should_count()

Whether the current request counts toward the rate limit.

private should_count(array{ip: string, path: string, method: string, script: string, action: string, is_ajax: bool} $context, string $scope) : bool
Parameters
$context : array{ip: string, path: string, method: string, script: string, action: string, is_ajax: bool}

Request context.

$scope : string

The configured scope.

Return values
bool

        
On this page

Search results