MediaWiki  master
MediaWiki\Auth\ThrottlePreAuthenticationProvider Class Reference

A pre-authentication provider to throttle authentication actions. More...

Inheritance diagram for MediaWiki\Auth\ThrottlePreAuthenticationProvider:
Collaboration diagram for MediaWiki\Auth\ThrottlePreAuthenticationProvider:

Public Member Functions

 __construct ( $params=[])
 
 postAuthentication ( $user, AuthenticationResponse $response)
 
 setConfig (Config $config)
 Set configuration. More...
 
 testForAccountCreation ( $user, $creator, array $reqs)
 Determine whether an account creation may begin. More...
 
 testForAuthentication (array $reqs)
 Determine whether an authentication may begin. More...
 
- Public Member Functions inherited from MediaWiki\Auth\AbstractPreAuthenticationProvider
 getAuthenticationRequests ( $action, array $options)
 Return the applicable list of AuthenticationRequests. More...
 
 postAccountCreation ( $user, $creator, AuthenticationResponse $response)
 Post-creation callback. More...
 
 postAccountLink ( $user, AuthenticationResponse $response)
 Post-link callback. More...
 
 postAuthentication ( $user, AuthenticationResponse $response)
 Post-login callback. More...
 
 testForAccountCreation ( $user, $creator, array $reqs)
 Determine whether an account creation may begin. More...
 
 testForAccountLink ( $user)
 Determine whether an account may linked to another authentication method. More...
 
 testForAuthentication (array $reqs)
 Determine whether an authentication may begin. More...
 
 testUserForCreation ( $user, $autocreate, array $options=[])
 Determine whether an account may be created. More...
 
- Public Member Functions inherited from MediaWiki\Auth\AbstractAuthenticationProvider
 getUniqueId ()
 
 setConfig (Config $config)
 Set configuration. More...
 
 setLogger (LoggerInterface $logger)
 
 setManager (AuthManager $manager)
 Set AuthManager. More...
 

Protected Attributes

Throttler $accountCreationThrottle
 
BagOStuff $cache
 
Throttler $passwordAttemptThrottle
 
array $throttleSettings
 
- Protected Attributes inherited from MediaWiki\Auth\AbstractAuthenticationProvider
Config $config
 
LoggerInterface $logger
 
AuthManager $manager
 

Detailed Description

A pre-authentication provider to throttle authentication actions.

Adding this provider will throttle account creations and primary authentication attempts (more specifically, any authentication that returns FAIL on failure). Secondary authentication cannot be easily throttled on a framework level (since it would typically return UI on failure); secondary providers are expected to do their own throttling.

Since
1.27

Definition at line 37 of file ThrottlePreAuthenticationProvider.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Auth\ThrottlePreAuthenticationProvider::__construct (   $params = [])
Parameters
array$params
  • accountCreationThrottle: (array) Condition array for the account creation throttle; an array of arrays in a format like $wgPasswordAttemptThrottle, passed to the Throttler constructor.
  • passwordAttemptThrottle: (array) Condition array for the password attempt throttle, in the same format as accountCreationThrottle.
  • cache: (BagOStuff) Where to store the throttle, defaults to the local cluster instance.

Definition at line 58 of file ThrottlePreAuthenticationProvider.php.

References $params, cache, and ObjectCache\getLocalClusterInstance().

Member Function Documentation

◆ postAuthentication()

MediaWiki\Auth\ThrottlePreAuthenticationProvider::postAuthentication (   $user,
AuthenticationResponse  $response 
)
Parameters
null | \\User$user
AuthenticationResponse$response

Implements MediaWiki\Auth\PreAuthenticationProvider.

Definition at line 160 of file ThrottlePreAuthenticationProvider.php.

References $name, $user, as, and MediaWiki\Auth\AuthenticationResponse\PASS.

◆ setConfig()

MediaWiki\Auth\ThrottlePreAuthenticationProvider::setConfig ( Config  $config)

◆ testForAccountCreation()

MediaWiki\Auth\ThrottlePreAuthenticationProvider::testForAccountCreation (   $user,
  $creator,
array  $reqs 
)

Determine whether an account creation may begin.

Called from AuthManager::beginAccountCreation()

Note
No need to test if the account exists, AuthManager checks that
Parameters
User$userUser being created (not added to the database yet). This may become a "UserValue" in the future, or User may be refactored into such.
User$creatorUser doing the creation. This may become a "UserValue" in the future, or User may be refactored into such.
AuthenticationRequest[]$reqs
Returns
StatusValue

Implements MediaWiki\Auth\PreAuthenticationProvider.

Definition at line 101 of file ThrottlePreAuthenticationProvider.php.

References null, Hooks\run(), and wfMessage().

◆ testForAuthentication()

MediaWiki\Auth\ThrottlePreAuthenticationProvider::testForAuthentication ( array  $reqs)

Determine whether an authentication may begin.

Called from AuthManager::beginAuthentication()

Parameters
AuthenticationRequest[]$reqs
Returns
StatusValue

Implements MediaWiki\Auth\PreAuthenticationProvider.

Definition at line 123 of file ThrottlePreAuthenticationProvider.php.

References $e, $name, $username, as, MediaWiki\Auth\AuthenticationRequest\getUsernameFromRequests(), and wfMessage().

Member Data Documentation

◆ $accountCreationThrottle

Throttler MediaWiki\Auth\ThrottlePreAuthenticationProvider::$accountCreationThrottle
protected

◆ $cache

BagOStuff MediaWiki\Auth\ThrottlePreAuthenticationProvider::$cache
protected

Definition at line 48 of file ThrottlePreAuthenticationProvider.php.

◆ $passwordAttemptThrottle

Throttler MediaWiki\Auth\ThrottlePreAuthenticationProvider::$passwordAttemptThrottle
protected

Definition at line 45 of file ThrottlePreAuthenticationProvider.php.

◆ $throttleSettings

array MediaWiki\Auth\ThrottlePreAuthenticationProvider::$throttleSettings
protected

Definition at line 39 of file ThrottlePreAuthenticationProvider.php.


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