MediaWiki fundraising/REL1_35
ApiAuthManagerHelper Class Reference

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

Collaboration diagram for ApiAuthManagerHelper:

Public Member Functions

 __construct (ApiBase $module, AuthManager $authManager=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, $result)
 Logs successful or failed authentication.
 
 securitySensitiveOperation ( $operation)
 Call $manager->securitySensitiveOperationStatus()
 

Static Public Member Functions

static blacklistAuthenticationRequests (array $reqs, array $blacklist)
 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.
 

Private Member Functions

 formatFields (array $fields)
 Clean up a field array for output.
 
 formatMessage (array &$res, $key, Message $message)
 Format a message for output.
 

Private Attributes

AuthManager $authManager
 
string $messageFormat
 Message output format.
 
ApiBase $module
 API module, for context and parameters.
 

Detailed Description

Helper class for AuthManager-using API modules.

Intended for use via composition.

Definition at line 37 of file ApiAuthManagerHelper.php.

Constructor & Destructor Documentation

◆ __construct()

ApiAuthManagerHelper::__construct ( ApiBase $module,
AuthManager $authManager = null )
Parameters
ApiBase$moduleAPI module, for context and parameters
AuthManager | null$authManager

Definition at line 52 of file ApiAuthManagerHelper.php.

References $authManager, $module, and ApiBase\extractRequestParams().

Member Function Documentation

◆ blacklistAuthenticationRequests()

static ApiAuthManagerHelper::blacklistAuthenticationRequests ( array $reqs,
array $blacklist )
static

Filter out authentication requests by class name.

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

Definition at line 129 of file ApiAuthManagerHelper.php.

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

◆ formatAuthenticationResponse()

ApiAuthManagerHelper::formatAuthenticationResponse ( AuthenticationResponse $res)

Format an AuthenticationResponse for return.

Parameters
AuthenticationResponse$res
Returns
array

Definition at line 194 of file ApiAuthManagerHelper.php.

References $res, formatMessage(), and formatRequests().

◆ formatFields()

ApiAuthManagerHelper::formatFields ( array $fields)
private

Clean up a field array for output.

Parameters
array$fields

-param array{type:string,options:array,value:string,label:Message,help:Message,optional:bool,sensitive:bool,skippable:bool} $fields

Returns
array

Definition at line 325 of file ApiAuthManagerHelper.php.

References $module, and formatMessage().

Referenced by formatRequests().

◆ formatMessage()

ApiAuthManagerHelper::formatMessage ( array & $res,
$key,
Message $message )
private

Format a message for output.

Parameters
array&$resResult array
string$keyResult key
Message$message

Definition at line 76 of file ApiAuthManagerHelper.php.

References $res, Message\getKey(), Message\getParams(), and Message\setContext().

Referenced by formatAuthenticationResponse(), formatFields(), and formatRequests().

◆ formatRequests()

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 279 of file ApiAuthManagerHelper.php.

References formatFields(), and formatMessage().

Referenced by formatAuthenticationResponse().

◆ getPreservedRequest()

ApiAuthManagerHelper::getPreservedRequest ( )

Fetch the preserved CreateFromLoginAuthenticationRequest, if any.

Returns
CreateFromLoginAuthenticationRequest|null

Definition at line 268 of file ApiAuthManagerHelper.php.

◆ getStandardParams()

static ApiAuthManagerHelper::getStandardParams ( $action,
$wantedParams )
static

Fetch the standard parameters this helper recognizes.

Parameters
string$actionAuthManager action
string...$wantedParams Parameters to use
Returns
array

Definition at line 362 of file ApiAuthManagerHelper.php.

Referenced by ApiAMCreateAccount\getAllowedParams(), ApiChangeAuthenticationData\getAllowedParams(), ApiClientLogin\getAllowedParams(), ApiLinkAccount\getAllowedParams(), ApiQueryAuthManagerInfo\getAllowedParams(), and ApiRemoveAuthenticationData\getAllowedParams().

◆ loadAuthenticationRequests()

ApiAuthManagerHelper::loadAuthenticationRequests ( $action)

Fetch and load the AuthenticationRequests for an action.

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

Definition at line 144 of file ApiAuthManagerHelper.php.

References MediaWiki\Auth\AuthenticationRequest\getUniqueId(), and true.

◆ logAuthenticationResult()

ApiAuthManagerHelper::logAuthenticationResult ( $event,
$result )

Logs successful or failed authentication.

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

Definition at line 245 of file ApiAuthManagerHelper.php.

References $module, and ApiBase\getModuleName().

◆ newForModule()

static 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 66 of file ApiAuthManagerHelper.php.

References $authManager, and $module.

Referenced by ApiRemoveAuthenticationData\execute().

◆ securitySensitiveOperation()

ApiAuthManagerHelper::securitySensitiveOperation ( $operation)

Call $manager->securitySensitiveOperationStatus()

Parameters
string$operationOperation being checked.
Exceptions
ApiUsageException

Definition at line 106 of file ApiAuthManagerHelper.php.

Member Data Documentation

◆ $authManager

AuthManager ApiAuthManagerHelper::$authManager
private

Definition at line 46 of file ApiAuthManagerHelper.php.

Referenced by __construct(), and newForModule().

◆ $messageFormat

string ApiAuthManagerHelper::$messageFormat
private

Message output format.

Definition at line 43 of file ApiAuthManagerHelper.php.

◆ $module

ApiBase ApiAuthManagerHelper::$module
private

API module, for context and parameters.

Definition at line 40 of file ApiAuthManagerHelper.php.

Referenced by __construct(), formatFields(), logAuthenticationResult(), and newForModule().


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