MediaWiki master
MediaWiki\Api\ApiAuthManagerHelper Class Reference

Helper class for AuthManager-using API modules. More...

Public Member Functions

 __construct (ApiBase $module, ?AuthManager $authManager=null, ?UserIdentityUtils $identityUtils=null)
 
 formatAuthenticationResponse (AuthenticationResponse $res)
 Format an AuthenticationResponse for return.
 
 formatRequests (array $reqs)
 Format an array of AuthenticationRequests for return.
 
 getPreservedRequest ()
 Fetch the preserved CreateFromLoginAuthenticationRequest, if any.
 
 loadAuthenticationRequests ( $action)
 Fetch and load the AuthenticationRequests for an action.
 
 logAuthenticationResult ( $event, UserIdentity $performer, AuthenticationResponse $result)
 Logs successful or failed authentication.
 
 securitySensitiveOperation ( $operation)
 Call $manager->securitySensitiveOperationStatus()
 

Static Public Member Functions

static blacklistAuthenticationRequests (array $reqs, array $remove)
 Filter out authentication requests by class name.
 
static getStandardParams ( $action,... $wantedParams)
 Fetch the standard parameters this helper recognizes.
 
static newForModule (ApiBase $module, ?AuthManager $authManager=null)
 Static version of the constructor, for chaining.
 

Detailed Description

Helper class for AuthManager-using API modules.

Intended for use via composition.

Definition at line 45 of file ApiAuthManagerHelper.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Api\ApiAuthManagerHelper::__construct ( ApiBase $module,
?AuthManager $authManager = null,
?UserIdentityUtils $identityUtils = null )
Parameters
ApiBase$moduleAPI module, for context and parameters
AuthManager | null$authManager
UserIdentityUtils | null$identityUtils

Definition at line 62 of file ApiAuthManagerHelper.php.

References $params, MediaWiki\Api\ApiBase\extractRequestParams(), and MediaWiki\MediaWikiServices\getInstance().

Member Function Documentation

◆ blacklistAuthenticationRequests()

static MediaWiki\Api\ApiAuthManagerHelper::blacklistAuthenticationRequests ( array $reqs,
array $remove )
static

Filter out authentication requests by class name.

Parameters
AuthenticationRequest[]$reqsRequests to filter
string[]$removeClass names to remove
Returns
AuthenticationRequest[]

Definition at line 147 of file ApiAuthManagerHelper.php.

Referenced by MediaWiki\Api\ApiChangeAuthenticationData\execute(), MediaWiki\Api\ApiClientLogin\execute(), and MediaWiki\Api\ApiQueryAuthManagerInfo\execute().

◆ formatAuthenticationResponse()

MediaWiki\Api\ApiAuthManagerHelper::formatAuthenticationResponse ( AuthenticationResponse $res)

Format an AuthenticationResponse for return.

Parameters
AuthenticationResponse$res
Returns
array

Definition at line 212 of file ApiAuthManagerHelper.php.

References MediaWiki\Api\ApiMessage\create(), and MediaWiki\Api\ApiAuthManagerHelper\formatRequests().

◆ formatRequests()

MediaWiki\Api\ApiAuthManagerHelper::formatRequests ( array $reqs)

Format an array of AuthenticationRequests for return.

Parameters
AuthenticationRequest[]$reqs
Returns
array Will have a 'requests' key, and also 'fields' if $module's params include 'mergerequestfields'.

Definition at line 295 of file ApiAuthManagerHelper.php.

References $params, and MediaWiki\Api\ApiResult\META_TYPE.

Referenced by MediaWiki\Api\ApiAuthManagerHelper\formatAuthenticationResponse().

◆ getPreservedRequest()

MediaWiki\Api\ApiAuthManagerHelper::getPreservedRequest ( )

Fetch the preserved CreateFromLoginAuthenticationRequest, if any.

Returns
CreateFromLoginAuthenticationRequest|null

Definition at line 284 of file ApiAuthManagerHelper.php.

◆ getStandardParams()

static MediaWiki\Api\ApiAuthManagerHelper::getStandardParams ( $action,
$wantedParams )
static

◆ loadAuthenticationRequests()

MediaWiki\Api\ApiAuthManagerHelper::loadAuthenticationRequests ( $action)

Fetch and load the AuthenticationRequests for an action.

Parameters
string$actionOne of the AuthManager::ACTION_* constants
Returns
AuthenticationRequest[]

Definition at line 162 of file ApiAuthManagerHelper.php.

References $params, and MediaWiki\Auth\AuthenticationRequest\getUniqueId().

◆ logAuthenticationResult()

MediaWiki\Api\ApiAuthManagerHelper::logAuthenticationResult ( $event,
UserIdentity $performer,
AuthenticationResponse $result )

Logs successful or failed authentication.

Parameters
string$eventEvent type (e.g. 'accountcreation')
UserIdentity$performer
AuthenticationResponse$resultResponse or error message

Definition at line 264 of file ApiAuthManagerHelper.php.

References MediaWiki\Api\ApiBase\getModuleName().

◆ newForModule()

static MediaWiki\Api\ApiAuthManagerHelper::newForModule ( ApiBase $module,
?AuthManager $authManager = null )
static

Static version of the constructor, for chaining.

Parameters
ApiBase$moduleAPI module, for context and parameters
AuthManager | null$authManager
Returns
ApiAuthManagerHelper

Definition at line 82 of file ApiAuthManagerHelper.php.

Referenced by MediaWiki\Api\ApiRemoveAuthenticationData\execute().

◆ securitySensitiveOperation()

MediaWiki\Api\ApiAuthManagerHelper::securitySensitiveOperation ( $operation)

Call $manager->securitySensitiveOperationStatus()

Parameters
string$operationOperation being checked.
Exceptions
ApiUsageException

Definition at line 122 of file ApiAuthManagerHelper.php.


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