MediaWiki master
MediaWiki\Auth\Throttler Class Reference

Inherits LoggerAwareInterface.

Collaboration diagram for MediaWiki\Auth\Throttler:

Public Member Functions

 __construct (array $conditions=null, array $params=[])
 clear ( $username=null, $ip=null)
 Clear the throttle counter.
 increase ( $username=null, $ip=null, $caller=null)
 Increase the throttle counter and return whether the attempt should be throttled.
 setLogger (LoggerInterface $logger)

Protected Member Functions

 logRejection (array $context)

Static Protected Member Functions

static normalizeThrottleConditions ( $throttleConditions)
 Handles B/C for $wgPasswordAttemptThrottle.

Protected Attributes

BagOStuff $cache
array[] $conditions
 See documentation of $wgPasswordAttemptThrottle for format.
LoggerInterface $logger
string $type
int float $warningLimit

Detailed Description

Definition at line 39 of file Throttler.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Auth\Throttler::__construct ( array $conditions = null,
array $params = [] )
array | null$conditionsAn array of arrays describing throttling conditions. Defaults to $wgPasswordAttemptThrottle. See documentation of that variable for format.
array$paramsParameters (all optional):
  • type: throttle type, used as a namespace for counters,
  • cache: a BagOStuff object where throttle counters are stored.
  • warningLimit: the log level will be raised to warning when rejecting an attempt after no less than this many failures.

Definition at line 65 of file Throttler.php.

References MediaWiki\Auth\Throttler\$conditions, $params, MediaWiki\MediaWikiServices\getInstance(), MediaWiki\MainConfigNames\PasswordAttemptThrottle, and MediaWiki\Auth\Throttler\setLogger().

Member Function Documentation

◆ clear()

MediaWiki\Auth\Throttler::clear ( $username = null,
$ip = null )

Clear the throttle counter.

Should be called after a successful authentication attempt.

string | null$username
string | null$ip

Definition at line 165 of file Throttler.php.

◆ increase()

MediaWiki\Auth\Throttler::increase ( $username = null,
$ip = null,
$caller = null )

Increase the throttle counter and return whether the attempt should be throttled.

Should be called before an authentication attempt.

string | null$username
string | null$ip
string | null$callerThe authentication method from which we were called.
array|false False if the attempt should not be throttled, an associative array with three keys otherwise:
  • throttleIndex: which throttle condition was met (a key of the conditions array)
  • count: throttle count (ie. number of failed attempts)
  • wait: time in seconds until authentication can be attempted

Definition at line 115 of file Throttler.php.

References MediaWiki\Auth\Throttler\logRejection().

◆ logRejection()

MediaWiki\Auth\Throttler::logRejection ( array $context)

Definition at line 208 of file Throttler.php.

Referenced by MediaWiki\Auth\Throttler\increase().

◆ normalizeThrottleConditions()

static MediaWiki\Auth\Throttler::normalizeThrottleConditions ( $throttleConditions)

Handles B/C for $wgPasswordAttemptThrottle.

See also
$wgPasswordAttemptThrottle for structure

Definition at line 198 of file Throttler.php.

◆ setLogger()

MediaWiki\Auth\Throttler::setLogger ( LoggerInterface $logger)

Definition at line 97 of file Throttler.php.

References MediaWiki\Auth\Throttler\$logger.

Referenced by MediaWiki\Auth\Throttler\__construct().

Member Data Documentation

◆ $cache

BagOStuff MediaWiki\Auth\Throttler::$cache

Definition at line 50 of file Throttler.php.

◆ $conditions

array [] MediaWiki\Auth\Throttler::$conditions

See documentation of $wgPasswordAttemptThrottle for format.

Old (pre-1.27) format is not allowed here.

See also$wgPasswordAttemptThrottle

Definition at line 48 of file Throttler.php.

Referenced by MediaWiki\Auth\Throttler\__construct().

◆ $logger

LoggerInterface MediaWiki\Auth\Throttler::$logger

Definition at line 52 of file Throttler.php.

Referenced by MediaWiki\Auth\Throttler\setLogger().

◆ $type

string MediaWiki\Auth\Throttler::$type

Definition at line 41 of file Throttler.php.

◆ $warningLimit

int float MediaWiki\Auth\Throttler::$warningLimit

Definition at line 54 of file Throttler.php.

The documentation for this class was generated from the following file: