MediaWiki  1.28.0
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 36 of file Throttler.php.

Constructor & Destructor Documentation

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

References MediaWiki\$config, $params, cache, conditions, Config\get(), ConfigFactory\getDefaultInstance(), MediaWiki\Logger\LoggerFactory\getInstance(), ObjectCache\getLocalClusterInstance(), MediaWiki\Auth\Throttler\setLogger(), and type.

Member Function Documentation

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 168 of file Throttler.php.

References $username, as, cache, conditions, type, and wfGlobalCacheKey().

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 112 of file Throttler.php.

References $count, $username, as, cache, conditions, MediaWiki\Auth\Throttler\logRejection(), type, and wfGlobalCacheKey().

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

Definition at line 193 of file Throttler.php.

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

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 183 of file Throttler.php.

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

Definition at line 94 of file Throttler.php.

References MediaWiki\Auth\Throttler\$logger.

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

Member Data Documentation

BagOStuff MediaWiki\Auth\Throttler::$cache
protected

Definition at line 47 of file Throttler.php.

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 45 of file Throttler.php.

LoggerInterface MediaWiki\Auth\Throttler::$logger
protected

Definition at line 49 of file Throttler.php.

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

string MediaWiki\Auth\Throttler::$type
protected

Definition at line 38 of file Throttler.php.

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

Definition at line 51 of file Throttler.php.


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