MediaWiki  master
MediaWiki\Auth\Throttler Class Reference
Inheritance diagram for MediaWiki\Auth\Throttler:
Collaboration diagram for MediaWiki\Auth\Throttler:

Public Member Functions

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

Protected Member Functions

 logRejection (array $context)
 

Static Protected Member Functions

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

Protected Attributes

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

Detailed Description

Definition at line 37 of file Throttler.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Auth\Throttler::__construct ( array  $conditions = null,
array  $params = [] 
)
Parameters
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 63 of file Throttler.php.

References MediaWiki\$config, Config\get(), MediaWiki\Logger\LoggerFactory\getInstance(), MediaWiki\MediaWikiServices\getInstance(), ObjectCache\getLocalClusterInstance(), 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.

Parameters
string | null$username
string | null$ip
Exceptions

Definition at line 170 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.

Parameters
string | null$username
string | null$ip
string | null$callerThe authentication method from which we were called.
Returns
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 113 of file Throttler.php.

References MediaWiki\Auth\Throttler\logRejection().

◆ logRejection()

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

Definition at line 195 of file Throttler.php.

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

◆ normalizeThrottleConditions()

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

Handles B/C for $wgPasswordAttemptThrottle.

Parameters
array$throttleConditions
Returns
array[]
See also
$wgPasswordAttemptThrottle for structure

Definition at line 185 of file Throttler.php.

◆ setLogger()

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

Definition at line 95 of file Throttler.php.

References MediaWiki\Auth\Throttler\$logger.

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

Member Data Documentation

◆ $cache

BagOStuff MediaWiki\Auth\Throttler::$cache
protected

Definition at line 48 of file Throttler.php.

◆ $conditions

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

See documentation of $wgPasswordAttemptThrottle for format.

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

See also
https://www.mediawiki.org/wiki/Manual:$wgPasswordAttemptThrottle

Definition at line 46 of file Throttler.php.

◆ $logger

LoggerInterface MediaWiki\Auth\Throttler::$logger
protected

Definition at line 50 of file Throttler.php.

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

◆ $type

string MediaWiki\Auth\Throttler::$type
protected

Definition at line 39 of file Throttler.php.

◆ $warningLimit

int float MediaWiki\Auth\Throttler::$warningLimit
protected

Definition at line 52 of file Throttler.php.


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