18 AuthManager::ACTION_LOGIN, AuthManager::ACTION_LOGIN_CONTINUE,
19 AuthManager::ACTION_CREATE, AuthManager::ACTION_CREATE_CONTINUE,
20 AuthManager::ACTION_LINK, AuthManager::ACTION_LINK_CONTINUE,
21 AuthManager::ACTION_CHANGE, AuthManager::ACTION_REMOVE, AuthManager::ACTION_UNLINK,
64 return $this->savedRequest ?: $this->
getContext()->getRequest();
77 if ( $wasPosted ===
null ) {
108 $authManager = AuthManager::singleton();
109 $key =
'AuthManagerSpecialPage:return:' . $this->
getName();
117 $preservedParams, [
'title' => 1 ] );
118 $authManager->setAuthenticationSessionData( $key, $authData );
125 $authData = $authManager->getAuthenticationSessionData( $key );
127 $authManager->removeAuthenticationSessionData( $key );
128 $this->isReturn =
true;
146 $authManager = AuthManager::singleton();
148 $key =
'AuthManagerSpecialPage:reauth:' . $this->
getName();
151 if ( $securityLevel ) {
152 $securityStatus = AuthManager::singleton()
153 ->securitySensitiveOperationStatus( $securityLevel );
154 if ( $securityStatus === AuthManager::SEC_REAUTH ) {
160 $key .=
':' . $uniqueId;
162 $queryParams = [
'authUniqueId' => $uniqueId ] +
$queryParams;
164 $this->getPreservedParams(
false ), [
'title' => 1 ] );
165 $authManager->setAuthenticationSessionData( $key, $authData );
169 $url = $title->getFullURL( [
170 'returnto' => $this->
getFullTitle()->getPrefixedDBkey(),
172 'force' => $securityLevel,
177 }
elseif ( $securityStatus !== AuthManager::SEC_OK ) {
178 throw new ErrorPageError(
'cannotauth-not-allowed-title',
'cannotauth-not-allowed' );
182 $uniqueId =
$request->getVal(
'authUniqueId' );
184 $key .=
':' . $uniqueId;
185 $authData = $authManager->getAuthenticationSessionData( $key );
187 $authManager->removeAuthenticationSessionData( $key );
236 !$reset && $this->subPage ===
$subPage && $this->authAction
245 if ( !
in_array( $this->authAction, static::$allowedActions,
true ) ) {
249 if (
in_array( $continueAction, static::$allowedActions,
true ) ) {
255 $allReqs = AuthManager::singleton()->getAuthenticationRequests(
256 $this->authAction, $this->
getUser() );
267 return in_array( $this->authAction, [
268 AuthManager::ACTION_LOGIN_CONTINUE,
269 AuthManager::ACTION_CREATE_CONTINUE,
270 AuthManager::ACTION_LINK_CONTINUE,
281 case AuthManager::ACTION_LOGIN:
282 $action = AuthManager::ACTION_LOGIN_CONTINUE;
284 case AuthManager::ACTION_CREATE:
285 $action = AuthManager::ACTION_CREATE_CONTINUE;
287 case AuthManager::ACTION_LINK:
288 $action = AuthManager::ACTION_LINK_CONTINUE;
303 $authManager = AuthManager::singleton();
304 if ( !
in_array( $action, static::$allowedActions,
true ) ) {
305 throw new InvalidArgumentException(
'invalid action: ' . $action );
310 : $authManager->getAuthenticationRequests( $action );
317 case AuthManager::ACTION_LOGIN:
318 case AuthManager::ACTION_LOGIN_CONTINUE:
319 return $authManager->canAuthenticateNow();
320 case AuthManager::ACTION_CREATE:
321 case AuthManager::ACTION_CREATE_CONTINUE:
322 return $authManager->canCreateAccounts();
323 case AuthManager::ACTION_LINK:
324 case AuthManager::ACTION_LINK_CONTINUE:
325 return $authManager->canLinkAccounts();
326 case AuthManager::ACTION_CHANGE:
327 case AuthManager::ACTION_REMOVE:
328 case AuthManager::ACTION_UNLINK:
332 throw new InvalidArgumentException(
'invalid action: ' . $action );
343 if ( !
in_array( $action, static::$allowedActions,
true ) ) {
344 throw new InvalidArgumentException(
'invalid action: ' . $action );
347 $authManager = AuthManager::singleton();
352 case AuthManager::ACTION_LOGIN:
353 return $authManager->beginAuthentication(
$requests, $returnToUrl );
354 case AuthManager::ACTION_LOGIN_CONTINUE:
355 return $authManager->continueAuthentication(
$requests );
356 case AuthManager::ACTION_CREATE:
357 return $authManager->beginAccountCreation( $this->
getUser(), $requests,
359 case AuthManager::ACTION_CREATE_CONTINUE:
360 return $authManager->continueAccountCreation(
$requests );
361 case AuthManager::ACTION_LINK:
362 return $authManager->beginAccountLink( $this->
getUser(), $requests, $returnToUrl );
363 case AuthManager::ACTION_LINK_CONTINUE:
364 return $authManager->continueAccountLink(
$requests );
365 case AuthManager::ACTION_CHANGE:
366 case AuthManager::ACTION_REMOVE:
367 case AuthManager::ACTION_UNLINK:
369 throw new InvalidArgumentException(
'only one auth request can be changed at a time' );
371 throw new InvalidArgumentException(
'no auth request' );
374 $status = $authManager->allowsAuthenticationDataChange(
$req );
375 Hooks::run(
'ChangeAuthenticationDataAudit', [
$req,
$status ] );
377 return AuthenticationResponse::newFail(
$status->getMessage() );
379 $authManager->changeAuthenticationData(
$req );
380 return AuthenticationResponse::newPass();
383 throw new InvalidArgumentException(
'invalid action: ' . $action );
400 $form = $this->
getAuthForm( $this->authRequests, $this->authAction );
401 $form->setSubmitCallback( [ $this,
'handleFormSubmit' ] );
407 if ( $sessionToken->wasNew() ) {
408 return Status::newFatal( $this->
messageKey(
'authform-newtoken' ) );
409 }
elseif ( !$requestTokenValue ) {
410 return Status::newFatal( $this->
messageKey(
'authform-notoken' ) );
411 }
elseif ( !$sessionToken->match( $requestTokenValue ) ) {
412 return Status::newFatal( $this->
messageKey(
'authform-wrongtoken' ) );
415 $form->prepareForm();
422 throw new UnexpectedValueException(
'HTMLForm::trySubmit() returned true' );
438 foreach (
$status as $message ) {
442 throw new UnexpectedValueException(
'invalid HTMLForm::trySubmit() return value: '
448 throw new UnexpectedValueException(
'invalid HTMLForm::trySubmit() return type: '
457 LoggerFactory::getInstance(
'authentication' )
458 ->warning(
'Validation error on return', [
'data' => $form->mFieldData,
459 'status' =>
$status->getWikiText(
false,
false,
'en' ) ] );
465 AuthManager::ACTION_CHANGE, AuthManager::ACTION_REMOVE, AuthManager::ACTION_UNLINK
468 Hooks::run(
'ChangeAuthenticationDataAudit', [ reset( $this->authRequests ),
$status ] );
481 $requests = AuthenticationRequest::loadRequestsFromSubmission( $this->authRequests,
$data );
513 $fieldInfo = AuthenticationRequest::mergeFieldInfo(
$requests );
529 if (
$context->getRequest() !== $this->getRequest() ) {
537 $form->addHiddenField(
'authAction', $this->authAction );
551 $form = $this->
getAuthForm( $this->authRequests, $this->authAction );
552 $form->prepareForm()->displayForm(
$status );
566 $customSubmitButtonPresent =
false;
573 if (
$req->required === AuthenticationRequest::PRIMARY_REQUIRED ) {
575 $customSubmitButtonPresent =
true;
590 foreach (
$req->getFieldInfo() as $field => $info ) {
591 if ( $info[
'type'] ===
'button' ) {
608 $class = $definition[
'class'];
610 $class = HTMLForm::$typeMappings[$definition[
'type']];
612 if ( $class !== HTMLInfoField::class ) {
613 $definition[
'tabindex'] =
$i;
624 return $this->
getRequest()->getSession()->getToken(
'AuthManagerSpecialPage:'
633 return 'wpAuthToken';
647 foreach ( $fieldInfo as $fieldName => $singleFieldInfo ) {
655 LoggerFactory::getInstance(
'authentication' )->warning(
656 'AuthChangeFormFields hook changed auth requests' );
681 if (
$type ===
'submit' &&
isset( $singleFieldInfo[
'label'] ) ) {
682 $descriptor[
'default'] = $singleFieldInfo[
'label']->plain();
686 'label-message' => self::getField( $singleFieldInfo,
'label' ),
689 if (
isset( $singleFieldInfo[
'options'] ) ) {
692 return $message->parse();
693 }, $singleFieldInfo[
'options'] ) );
696 if (
isset( $singleFieldInfo[
'value'] ) ) {
697 $descriptor[
'default'] = $singleFieldInfo[
'value'];
700 if ( empty( $singleFieldInfo[
'optional'] ) ) {
701 $descriptor[
'required'] =
true;
717 $field[
'__index'] = $i++;
721 ?: $first[
'__index'] <=> $second[
'__index'];
724 unset( $field[
'__index'] );
735 protected static function getField(
array $array, $fieldName, $default =
null ) {
752 'password' =>
'password',
753 'select' =>
'select',
754 'checkbox' =>
'check',
755 'multiselect' =>
'multiselect',
756 'button' =>
'submit',
757 'hidden' =>
'hidden',
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
wfArrayToCgi( $array1, $array2=null, $prefix='')
This function takes one or two arrays as input, and returns a CGI-style string, e....
A special page subclass for authentication-related special pages.
getContinueAction( $action)
Gets the _CONTINUE version of an action.
handleReturnBeforeExecute( $subPage)
Handle redirection from the /return subpage.
getLoginSecurityLevel()
Tells if the special page does something security-sensitive and needs extra defense against a stolen ...
handleReauthBeforeExecute( $subPage)
Handle redirection when the user needs to (re)authenticate.
beforeExecute( $subPage)
Gets called before.
isActionAllowed( $action)
Checks whether AuthManager is ready to perform the action.
WebRequest null $savedRequest
If set, will be used instead of the real request.
string $authAction
one of the AuthManager::ACTION_* constants.
performAuthenticationStep( $action, array $requests)
getAuthForm(array $requests, $action)
displayForm( $status)
Display the form.
loadAuth( $subPage, $authAction=null, $reset=false)
Load or initialize $authAction, $authRequests and $subPage.
bool $isReturn
True if the current request is a result of returning from a redirect flow.
static mapFieldInfoTypeToFormDescriptorType( $type)
Maps AuthenticationRequest::getFieldInfo() types to HTMLForm types.
fieldInfoToFormDescriptor(array $requests, array $fieldInfo, $action)
Turns a field info array into a form descriptor.
getDefaultAction( $subPage)
Get the default action for this special page, if none is given via URL/POST data.
handleFormSubmit( $data)
Submit handler callback for HTMLForm.
static array $messages
Customized messages.
AuthenticationRequest[] $authRequests
needsSubmitButton(array $requests)
Returns true if the form built from the given AuthenticationRequests needs a submit button.
string $subPage
Subpage of the special page.
isContinued()
Returns true if this is not the first step of the authentication.
hasOwnSubmitButton(AuthenticationRequest $req)
Checks whether the given AuthenticationRequest has its own submit button.
getRequestBlacklist()
Allows blacklisting certain request types.
static mapSingleFieldInfo( $singleFieldInfo, $fieldName)
Maps an authentication field configuration for a single field (as returned by AuthenticationRequest::...
static getField(array $array, $fieldName, $default=null)
Get an array value, or a default if it does not exist.
getRequest()
Get the WebRequest being used for this instance.
messageKey( $defaultKey)
Return custom message key.
setRequest(array $data, $wasPosted=null)
Override the POST data, GET data from the real request is preserved.
trySubmit()
Attempts to do an authentication step with the submitted data.
getToken()
Returns the CSRF token.
static sortFormDescriptorFields(array &$formDescriptor)
Sort the fields of a form descriptor by their 'weight' property.
addTabIndex(&$formDescriptor)
Adds a sequential tabindex starting from 1 to all form elements.
getAuthFormDescriptor( $requests, $action)
Generates a HTMLForm descriptor array from a set of authentication requests.
onAuthChangeFormFields(array $requests, array $fieldInfo, array &$formDescriptor, $action)
Change the form descriptor that determines how a field will look in the authentication form.
getPreservedParams( $withToken=false)
Returns URL query parameters which can be used to reload the page (or leave and return) while preserv...
getTokenName()
Returns the name of the CSRF token (under which it should be found in the POST or GET data).
static string[] $allowedActions
The list of actions this special page deals with.
An IContextSource implementation which will inherit context from another source but allow individual ...
Similar to FauxRequest, but only fakes URL parameters and method (POST or GET) and use the base reque...
An error page which can definitely be safely rendered using the OutputPage.
static generateHex( $chars)
Generate a run of cryptographically random data and return it in hexadecimal string format.
Variant of the Message class.
Parent class for all special pages.
getName()
Get the name of this Special Page.
getOutput()
Get the OutputPage being used for this instance.
getUser()
Shortcut to get the User executing this instance.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
getContext()
Gets the context this SpecialPage is executed in.
getPageTitle( $subpage=false)
Get a self-referential title object.
getFullTitle()
Return the full title, including $par.
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Generic operation result class Has warning/error list, boolean status and arbitrary value.
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping il...
this hook is for auditing only $req
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on $request
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation use $formDescriptor instead & $formDescriptor
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
Allows to change the fields on the form that will be generated are created Can be used to omit specific feeds from being outputted You must not use this hook to add use OutputPage::addFeedLink() instead. & $feedLinks hooks can tweak the array to change how login etc forms should look $requests
Status::newGood()` to allow deletion, and then `return false` from the hook function. Ensure you consume the 'ChangeTagAfterDelete' hook to carry out custom deletion actions. $tag:name of the tag $user:user initiating the action & $status:Status object. See above. 'ChangeTagsListActive':Allows you to nominate which of the tags your extension uses are in active use. & $tags:list of all active tags. Append to this array. 'ChangeTagsAfterUpdateTags':Called after tags have been updated with the ChangeTags::updateTags function. Params:$addedTags:tags effectively added in the update $removedTags:tags effectively removed in the update $prevTags:tags that were present prior to the update $rc_id:recentchanges table id $rev_id:revision table id $log_id:logging table id $params:tag params $rc:RecentChange being tagged when the tagging accompanies the action, or null $user:User who performed the tagging when the tagging is subsequent to the action, or null 'ChangeTagsAllowedAdd':Called when checking if a user can add tags to a change. & $allowedTags:List of all the tags the user is allowed to add. Any tags the user wants to add( $addTags) that are not in this array will cause it to fail. You may add or remove tags to this array as required. $addTags:List of tags user intends to add. $user:User who is adding the tags. 'ChangeUserGroups':Called before user groups are changed. $performer:The User who will perform the change $user:The User whose groups will be changed & $add:The groups that will be added & $remove:The groups that will be removed 'Collation::factory':Called if $wgCategoryCollation is an unknown collation. $collationName:Name of the collation in question & $collationObject:Null. Replace with a subclass of the Collation class that implements the collation given in $collationName. 'ConfirmEmailComplete':Called after a user 's email has been confirmed successfully. $user:user(object) whose email is being confirmed 'ContentAlterParserOutput':Modify parser output for a given content object. Called by Content::getParserOutput after parsing has finished. Can be used for changes that depend on the result of the parsing but have to be done before LinksUpdate is called(such as adding tracking categories based on the rendered HTML). $content:The Content to render $title:Title of the page, as context $parserOutput:ParserOutput to manipulate 'ContentGetParserOutput':Customize parser output for a given content object, called by AbstractContent::getParserOutput. May be used to override the normal model-specific rendering of page content. $content:The Content to render $title:Title of the page, as context $revId:The revision ID, as context $options:ParserOptions for rendering. To avoid confusing the parser cache, the output can only depend on parameters provided to this hook function, not on global state. $generateHtml:boolean, indicating whether full HTML should be generated. If false, generation of HTML may be skipped, but other information should still be present in the ParserOutput object. & $output:ParserOutput, to manipulate or replace 'ContentHandlerDefaultModelFor':Called when the default content model is determined for a given title. May be used to assign a different model for that title. $title:the Title in question & $model:the model name. Use with CONTENT_MODEL_XXX constants. 'ContentHandlerForModelID':Called when a ContentHandler is requested for a given content model name, but no entry for that model exists in $wgContentHandlers. Note:if your extension implements additional models via this hook, please use GetContentModels hook to make them known to core. $modeName:the requested content model name & $handler:set this to a ContentHandler object, if desired. 'ContentModelCanBeUsedOn':Called to determine whether that content model can be used on a given page. This is especially useful to prevent some content models to be used in some special location. $contentModel:ID of the content model in question $title:the Title in question. & $ok:Output parameter, whether it is OK to use $contentModel on $title. Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok. 'ContribsPager::getQueryInfo':Before the contributions query is about to run & $pager:Pager object for contributions & $queryInfo:The query for the contribs Pager 'ContribsPager::reallyDoQuery':Called before really executing the query for My Contributions & $data:an array of results of all contribs queries $pager:The ContribsPager object hooked into $offset:Index offset, inclusive $limit:Exact query limit $descending:Query direction, false for ascending, true for descending 'ContributionsLineEnding':Called before a contributions HTML line is finished $page:SpecialPage object for contributions & $ret:the HTML line $row:the DB row for this line & $classes:the classes to add to the surrounding< li > & $attribs:associative array of other HTML attributes for the< li > element. Currently only data attributes reserved to MediaWiki are allowed(see Sanitizer::isReservedDataAttribute). 'ContributionsToolLinks':Change tool links above Special:Contributions $id:User identifier $title:User page title & $tools:Array of tool links $specialPage:SpecialPage instance for context and services. Can be either SpecialContributions or DeletedContributionsPage. Extensions should type hint against a generic SpecialPage though. 'ConvertContent':Called by AbstractContent::convert when a conversion to another content model is requested. Handler functions that modify $result should generally return false to disable further attempts at conversion. $content:The Content object to be converted. $toModel:The ID of the content model to convert to. $lossy: boolean indicating whether lossy conversion is allowed. & $result:Output parameter, in case the handler function wants to provide a converted Content object. Note that $result->getContentModel() must return $toModel. 'ContentSecurityPolicyDefaultSource':Modify the allowed CSP load sources. This affects all directives except for the script directive. If you want to add a script source, see ContentSecurityPolicyScriptSource hook. & $defaultSrc:Array of Content-Security-Policy allowed sources $policyConfig:Current configuration for the Content-Security-Policy header $mode:ContentSecurityPolicy::REPORT_ONLY_MODE or ContentSecurityPolicy::FULL_MODE depending on type of header 'ContentSecurityPolicyDirectives':Modify the content security policy directives. Use this only if ContentSecurityPolicyDefaultSource and ContentSecurityPolicyScriptSource do not meet your needs. & $directives:Array of CSP directives $policyConfig:Current configuration for the CSP header $mode:ContentSecurityPolicy::REPORT_ONLY_MODE or ContentSecurityPolicy::FULL_MODE depending on type of header 'ContentSecurityPolicyScriptSource':Modify the allowed CSP script sources. Note that you also have to use ContentSecurityPolicyDefaultSource if you want non-script sources to be loaded from whatever you add. & $scriptSrc:Array of CSP directives $policyConfig:Current configuration for the CSP header $mode:ContentSecurityPolicy::REPORT_ONLY_MODE or ContentSecurityPolicy::FULL_MODE depending on type of header 'CustomEditor':When invoking the page editor Return true to allow the normal editor to be used, or false if implementing a custom editor, e.g. for a special namespace, etc. $article:Article being edited $user:User performing the edit 'DatabaseOraclePostInit':Called after initialising an Oracle database $db:the DatabaseOracle object 'DeletedContribsPager::reallyDoQuery':Called before really executing the query for Special:DeletedContributions Similar to ContribsPager::reallyDoQuery & $data:an array of results of all contribs queries $pager:The DeletedContribsPager object hooked into $offset:Index offset, inclusive $limit:Exact query limit $descending:Query direction, false for ascending, true for descending 'DeletedContributionsLineEnding':Called before a DeletedContributions HTML line is finished. Similar to ContributionsLineEnding $page:SpecialPage object for DeletedContributions & $ret:the HTML line $row:the DB row for this line & $classes:the classes to add to the surrounding< li > & $attribs:associative array of other HTML attributes for the< li > element. Currently only data attributes reserved to MediaWiki are allowed(see Sanitizer::isReservedDataAttribute). 'DeleteUnknownPreferences':Called by the cleanupPreferences.php maintenance script to build a WHERE clause with which to delete preferences that are not known about. This hook is used by extensions that have dynamically-named preferences that should not be deleted in the usual cleanup process. For example, the Gadgets extension creates preferences prefixed with 'gadget-', and so anything with that prefix is excluded from the deletion. &where:An array that will be passed as the $cond parameter to IDatabase::select() to determine what will be deleted from the user_properties table. $db:The IDatabase object, useful for accessing $db->buildLike() etc. 'DifferenceEngineAfterLoadNewText':called in DifferenceEngine::loadNewText() after the new revision 's content has been loaded into the class member variable $differenceEngine->mNewContent but before returning true from this function. $differenceEngine:DifferenceEngine object 'DifferenceEngineLoadTextAfterNewContentIsLoaded':called in DifferenceEngine::loadText() after the new revision 's content has been loaded into the class member variable $differenceEngine->mNewContent but before checking if the variable 's value is null. This hook can be used to inject content into said class member variable. $differenceEngine:DifferenceEngine object 'DifferenceEngineMarkPatrolledLink':Allows extensions to change the "mark as
patrolled" link which is shown both on the diff header as well as on the bottom of a page, usually wrapped in a span element which has class="patrollink". $differenceEngine:DifferenceEngine object & $markAsPatrolledLink:The "mark as patrolled" link HTML(string) $rcid:Recent change ID(rc_id) for this change(int) 'DifferenceEngineMarkPatrolledRCID':Allows extensions to possibly change the rcid parameter. For example the rcid might be set to zero due to the user being the same as the performer of the change but an extension might still want to show it under certain conditions. & $rcid:rc_id(int) of the change or 0 $differenceEngine:DifferenceEngine object $change:RecentChange object $user:User object representing the current user 'DifferenceEngineNewHeader':Allows extensions to change the $newHeader variable, which contains information about the new revision, such as the revision 's author, whether the revision was marked as a minor edit or not, etc. $differenceEngine:DifferenceEngine object & $newHeader:The string containing the various #mw-diff-otitle[1-5] divs, which include things like revision author info, revision comment, RevisionDelete link and more $formattedRevisionTools:Array containing revision tools, some of which may have been injected with the DiffRevisionTools hook $nextlink:String containing the link to the next revision(if any) $status
this hook is for auditing only $response
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))