MediaWiki  1.29.1
CaptchaPreAuthenticationProviderTest.php
Go to the documentation of this file.
1 <?php
2 
5 use Wikimedia\TestingAccessWrapper;
6 
11  public function setUp() {
12  global $wgDisableAuthManager;
13  if ( !class_exists( AuthManager::class ) || $wgDisableAuthManager ) {
14  $this->markTestSkipped( 'AuthManager is disabled' );
15  }
16 
17  parent::setUp();
18  $this->setMwGlobals( [
19  'wgCaptchaClass' => SimpleCaptcha::class,
20  'wgCaptchaBadLoginAttempts' => 1,
21  'wgCaptchaBadLoginPerUserAttempts' => 1,
22  'wgCaptchaStorageClass' => CaptchaHashStore::class,
23  'wgMainCacheType' => __METHOD__,
24  ] );
26  CaptchaStore::get()->clearAll();
27  $services = \MediaWiki\MediaWikiServices::getInstance();
28  if ( method_exists( $services, 'getLocalClusterObjectCache' ) ) {
29  $this->setService( 'LocalClusterObjectCache', new HashBagOStuff() );
30  } else {
31  ObjectCache::$instances[__METHOD__] = new HashBagOStuff();
32  }
33  }
34 
35  public function tearDown() {
36  parent::tearDown();
37  // make sure $wgCaptcha resets between tests
38  TestingAccessWrapper::newFromClass( 'ConfirmEditHooks' )->instanceCreated = false;
39  }
40 
45  $action, $username, $triggers, $needsCaptcha, $preTestCallback = null
46  ) {
47  $this->setTriggers( $triggers );
48  if ( $preTestCallback ) {
49  $fn = array_shift( $preTestCallback );
50  call_user_func_array( [ $this, $fn ], $preTestCallback );
51  }
52 
54  $request = RequestContext::getMain()->getRequest();
55  $request->setCookie( 'UserName', $username );
56 
57  $provider = new CaptchaPreAuthenticationProvider();
58  $provider->setManager( AuthManager::singleton() );
59  $reqs = $provider->getAuthenticationRequests( $action, [ 'username' => $username ] );
60  if ( $needsCaptcha ) {
61  $this->assertCount( 1, $reqs );
62  $this->assertInstanceOf( CaptchaAuthenticationRequest::class, $reqs[0] );
63  } else {
64  $this->assertEmpty( $reqs );
65  }
66  }
67 
69  return [
70  [ AuthManager::ACTION_LOGIN, null, [], false ],
71  [ AuthManager::ACTION_LOGIN, null, [ 'badlogin' ], false ],
72  [ AuthManager::ACTION_LOGIN, null, [ 'badlogin' ], true, [ 'blockLogin', 'Foo' ] ],
73  [ AuthManager::ACTION_LOGIN, null, [ 'badloginperuser' ], false, [ 'blockLogin', 'Foo' ] ],
74  [ AuthManager::ACTION_LOGIN, 'Foo', [ 'badloginperuser' ], false, [ 'blockLogin', 'Bar' ] ],
75  [ AuthManager::ACTION_LOGIN, 'Foo', [ 'badloginperuser' ], true, [ 'blockLogin', 'Foo' ] ],
76  [ AuthManager::ACTION_LOGIN, null, [ 'badloginperuser' ], true, [ 'flagSession' ] ],
77  [ AuthManager::ACTION_CREATE, null, [], false ],
78  [ AuthManager::ACTION_CREATE, null, [ 'createaccount' ], true ],
79  [ AuthManager::ACTION_CREATE, 'UTSysop', [ 'createaccount' ], false ],
80  [ AuthManager::ACTION_LINK, null, [], false ],
81  [ AuthManager::ACTION_CHANGE, null, [], false ],
82  [ AuthManager::ACTION_REMOVE, null, [], false ],
83  ];
84  }
85 
87  $this->setTriggers( [ 'createaccount' ] );
88  $captcha = new SimpleCaptcha();
89  $provider = new CaptchaPreAuthenticationProvider();
90  $provider->setManager( AuthManager::singleton() );
91 
92  $reqs = $provider->getAuthenticationRequests( AuthManager::ACTION_CREATE,
93  [ 'username' => 'Foo' ] );
94 
95  $this->assertCount( 1, $reqs );
96  $this->assertInstanceOf( CaptchaAuthenticationRequest::class, $reqs[0] );
97 
98  $id = $reqs[0]->captchaId;
99  $data = TestingAccessWrapper::newFromObject( $reqs[0] )->captchaData;
100  $this->assertEquals( $captcha->retrieveCaptcha( $id ), $data + [ 'index' => $id ] );
101  }
102 
106  public function testTestForAuthentication( $req, $isBadLoginTriggered,
107  $isBadLoginPerUserTriggered, $result
108  ) {
109  $this->setMwHook( 'PingLimiter', function ( $user, $action, &$result ) {
110  $result = false;
111  return false;
112  } );
113  CaptchaStore::get()->store( '345', [ 'question' => '2+2', 'answer' => '4' ] );
114  $captcha = $this->getMock( SimpleCaptcha::class,
115  [ 'isBadLoginTriggered', 'isBadLoginPerUserTriggered' ] );
116  $captcha->expects( $this->any() )->method( 'isBadLoginTriggered' )
117  ->willReturn( $isBadLoginTriggered );
118  $captcha->expects( $this->any() )->method( 'isBadLoginPerUserTriggered' )
119  ->willReturn( $isBadLoginPerUserTriggered );
120  $this->setMwGlobals( 'wgCaptcha', $captcha );
121  TestingAccessWrapper::newFromClass( 'ConfirmEditHooks' )->instanceCreated = true;
122  $provider = new CaptchaPreAuthenticationProvider();
123  $provider->setManager( AuthManager::singleton() );
124 
125  $status = $provider->testForAuthentication( $req ? [ $req ] : [] );
126  $this->assertEquals( $result, $status->isGood() );
127  }
128 
129  public function provideTestForAuthentication() {
131  $fallback->username = 'Foo';
132  return [
133  // [ auth request, bad login?, bad login per user?, result ]
134  'no need to check' => [ $fallback, false, false, true ],
135  'badlogin' => [ $fallback, true, false, false ],
136  'badloginperuser, no username' => [ null, false, true, true ],
137  'badloginperuser' => [ $fallback, false, true, false ],
138  'non-existent captcha' => [ $this->getCaptchaRequest( '123', '4' ), true, true, false ],
139  'wrong captcha' => [ $this->getCaptchaRequest( '345', '6' ), true, true, false ],
140  'correct captcha' => [ $this->getCaptchaRequest( '345', '4' ), true, true, true ],
141  ];
142  }
143 
147  public function testTestForAccountCreation( $req, $creator, $result, $disableTrigger = false ) {
148  $this->setMwHook( 'PingLimiter', function ( &$user, $action, &$result ) {
149  $result = false;
150  return false;
151  } );
152  $this->setTriggers( $disableTrigger ? [] : [ 'createaccount' ] );
153  CaptchaStore::get()->store( '345', [ 'question' => '2+2', 'answer' => '4' ] );
154  $user = User::newFromName( 'Foo' );
155  $provider = new CaptchaPreAuthenticationProvider();
156  $provider->setManager( AuthManager::singleton() );
157 
158  $status = $provider->testForAccountCreation( $user, $creator, $req ? [ $req ] : [] );
159  $this->assertEquals( $result, $status->isGood() );
160  }
161 
162  public function provideTestForAccountCreation() {
163  $user = User::newFromName( 'Bar' );
164  $sysop = User::newFromName( 'UTSysop' );
165  return [
166  // [ auth request, creator, result, disable trigger? ]
167  'no captcha' => [ null, $user, false ],
168  'non-existent captcha' => [ $this->getCaptchaRequest( '123', '4' ), $user, false ],
169  'wrong captcha' => [ $this->getCaptchaRequest( '345', '6' ), $user, false ],
170  'correct captcha' => [ $this->getCaptchaRequest( '345', '4' ), $user, true ],
171  'user is exempt' => [ null, $sysop, true ],
172  'disabled' => [ null, $user, true, 'disable' ],
173  ];
174  }
175 
176  public function testPostAuthentication() {
177  $this->setTriggers( [ 'badlogin', 'badloginperuser' ] );
178  $captcha = new SimpleCaptcha();
179  $user = User::newFromName( 'Foo' );
180  $anotherUser = User::newFromName( 'Bar' );
181  $provider = new CaptchaPreAuthenticationProvider();
182  $provider->setManager( AuthManager::singleton() );
183 
184  $this->assertFalse( $captcha->isBadLoginTriggered() );
185  $this->assertFalse( $captcha->isBadLoginPerUserTriggered( $user ) );
186 
187  $provider->postAuthentication( $user, \MediaWiki\Auth\AuthenticationResponse::newFail(
188  wfMessage( '?' ) ) );
189 
190  $this->assertTrue( $captcha->isBadLoginTriggered() );
191  $this->assertTrue( $captcha->isBadLoginPerUserTriggered( $user ) );
192  $this->assertFalse( $captcha->isBadLoginPerUserTriggered( $anotherUser ) );
193 
194  $provider->postAuthentication( $user, \MediaWiki\Auth\AuthenticationResponse::newPass( 'Foo' ) );
195 
196  $this->assertFalse( $captcha->isBadLoginPerUserTriggered( $user ) );
197  }
198 
200  $this->setTriggers( [] );
201  $captcha = new SimpleCaptcha();
202  $user = User::newFromName( 'Foo' );
203  $provider = new CaptchaPreAuthenticationProvider();
204  $provider->setManager( AuthManager::singleton() );
205 
206  $this->assertFalse( $captcha->isBadLoginTriggered() );
207  $this->assertFalse( $captcha->isBadLoginPerUserTriggered( $user ) );
208 
209  $provider->postAuthentication( $user, \MediaWiki\Auth\AuthenticationResponse::newFail(
210  wfMessage( '?' ) ) );
211 
212  $this->assertFalse( $captcha->isBadLoginTriggered() );
213  $this->assertFalse( $captcha->isBadLoginPerUserTriggered( $user ) );
214  }
215 
219  public function testPingLimiter( array $attempts ) {
221  'wgRateLimits',
222  [
223  'badcaptcha' => [
224  'user' => [ 1, 1 ],
225  ],
226  ]
227  );
228  $provider = new CaptchaPreAuthenticationProvider();
229  $provider->setManager( AuthManager::singleton() );
230  $providerAccess = TestingAccessWrapper::newFromObject( $provider );
231 
232  foreach ( $attempts as $attempt ) {
233  if ( !empty( $attempts[3] ) ) {
234  $this->setMwHook( 'PingLimiter', function ( &$user, $action, &$result ) {
235  $result = false;
236  return false;
237  } );
238  } else {
239  $this->setMwHook( 'PingLimiter', function () {
240  } );
241  }
242 
243  $captcha = new SimpleCaptcha();
244  CaptchaStore::get()->store( '345', [ 'question' => '7+7', 'answer' => '14' ] );
245  $success = $providerAccess->verifyCaptcha( $captcha, [ $attempts[0] ], $attempts[1] );
246  $this->assertEquals( $attempts[2], $success );
247  }
248  }
249 
250  public function providePingLimiter() {
251  $sysop = User::newFromName( 'UTSysop' );
252  return [
253  // sequence of [ auth request, user, result, disable ping limiter? ]
254  'no failure' => [
255  [ $this->getCaptchaRequest( '345', '14' ), new User(), true ],
256  [ $this->getCaptchaRequest( '345', '14' ), new User(), true ],
257  ],
258  'limited' => [
259  [ $this->getCaptchaRequest( '345', '33' ), new User(), false ],
260  [ $this->getCaptchaRequest( '345', '14' ), new User(), false ],
261  ],
262  'exempt user' => [
263  [ $this->getCaptchaRequest( '345', '33' ), $sysop, false ],
264  [ $this->getCaptchaRequest( '345', '14' ), $sysop, true ],
265  ],
266  'pinglimiter disabled' => [
267  [ $this->getCaptchaRequest( '345', '33' ), new User(), false, 'disable' ],
268  [ $this->getCaptchaRequest( '345', '14' ), new User(), true, 'disable' ],
269  ],
270  ];
271  }
272 
273  protected function getCaptchaRequest( $id, $word, $username = null ) {
274  $req = new CaptchaAuthenticationRequest( $id, [ 'question' => '?', 'answer' => $word ] );
275  $req->captchaWord = $word;
276  $req->username = $username;
277  return $req;
278  }
279 
280  protected function blockLogin( $username ) {
281  $captcha = new SimpleCaptcha();
282  $captcha->increaseBadLoginCounter( $username );
283  }
284 
285  protected function flagSession() {
286  RequestContext::getMain()->getRequest()->getSession()
287  ->set( 'ConfirmEdit:loginCaptchaPerUserTriggered', true );
288  }
289 
290  protected function setTriggers( $triggers ) {
291  $types = [ 'edit', 'create', 'sendemail', 'addurl', 'createaccount', 'badlogin',
292  'badloginperuser' ];
293  $captchaTriggers = array_combine( $types, array_map( function ( $type ) use ( $triggers ) {
294  return in_array( $type, $triggers, true );
295  }, $types ) );
296  $this->setMwGlobals( 'wgCaptchaTriggers', $captchaTriggers );
297  }
298 
305  protected function setMwHook( $hook, callable $callback ) {
306  $this->mergeMwGlobalArrayValue( 'wgHooks', [ $hook => $callback ] );
307  }
308 }
CaptchaPreAuthenticationProviderTest\testGetAuthenticationRequests_store
testGetAuthenticationRequests_store()
Definition: CaptchaPreAuthenticationProviderTest.php:86
CaptchaStore\get
static get()
Get somewhere to store captcha data that will persist between requests.
Definition: CaptchaStore.php:44
$request
error also a ContextSource you ll probably need to make sure the header is varied on $request
Definition: hooks.txt:2612
false
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:189
MediaWikiTestCase\mergeMwGlobalArrayValue
mergeMwGlobalArrayValue( $name, $values)
Merges the given values into a MW global array variable.
Definition: MediaWikiTestCase.php:766
HashBagOStuff
Simple store for keeping values in an associative array for the current process.
Definition: HashBagOStuff.php:31
CaptchaPreAuthenticationProviderTest\provideTestForAuthentication
provideTestForAuthentication()
Definition: CaptchaPreAuthenticationProviderTest.php:129
CaptchaPreAuthenticationProviderTest\tearDown
tearDown()
Definition: CaptchaPreAuthenticationProviderTest.php:35
$fallback
$fallback
Definition: MessagesAb.php:11
$result
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page. Return false to stop further processing of the tag $reader:XMLReader object & $pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports. & $fullInterwikiPrefix:Interwiki prefix, may contain colons. & $pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable. Can be used to lazy-load the import sources list. & $importSources:The value of $wgImportSources. Modify as necessary. See the comment in DefaultSettings.php for the detail of how to structure this array. 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. & $title:Title object for the current page & $request:WebRequest & $ignoreRedirect:boolean to skip redirect check & $target:Title/string of redirect target & $article:Article object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) & $article:article(object) being checked 'IsTrustedProxy':Override the result of IP::isTrustedProxy() & $ip:IP being check & $result:Change this value to override the result of IP::isTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of Sanitizer::validateEmail(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetMagic':DEPRECATED! Use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language & $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetSpecialPageAliases':DEPRECATED! Use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language & $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code:language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Array with elements of the form "language:title" in the order that they will be output. & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LanguageSelector':Hook to change the language selector available on a page. $out:The output page. $cssClassName:CSS class name of the language selector. 'LinkBegin':DEPRECATED! Use HtmlPageLinkRendererBegin instead. Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
Definition: hooks.txt:1954
$status
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set $status
Definition: hooks.txt:1049
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
ObjectCache\$instances
static BagOStuff[] $instances
Map of (id => BagOStuff)
Definition: ObjectCache.php:82
$user
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
Definition: hooks.txt:246
$req
this hook is for auditing only $req
Definition: hooks.txt:990
User\newFromName
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition: User.php:556
CaptchaPreAuthenticationProviderTest\provideTestForAccountCreation
provideTestForAccountCreation()
Definition: CaptchaPreAuthenticationProviderTest.php:162
$success
$success
Definition: NoLocalSettings.php:44
User
User
Definition: All_system_messages.txt:425
$type
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
Definition: hooks.txt:2536
CaptchaStore\unsetInstanceForTests
static unsetInstanceForTests()
Definition: CaptchaStore.php:56
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
CaptchaPreAuthenticationProviderTest\setMwHook
setMwHook( $hook, callable $callback)
Set a $wgHooks handler for a given hook and remove all other handlers (though not ones set via Hooks:...
Definition: CaptchaPreAuthenticationProviderTest.php:305
CaptchaPreAuthenticationProviderTest\testGetAuthenticationRequests
testGetAuthenticationRequests( $action, $username, $triggers, $needsCaptcha, $preTestCallback=null)
provideGetAuthenticationRequests
Definition: CaptchaPreAuthenticationProviderTest.php:44
CaptchaPreAuthenticationProviderTest\testTestForAuthentication
testTestForAuthentication( $req, $isBadLoginTriggered, $isBadLoginPerUserTriggered, $result)
provideTestForAuthentication
Definition: CaptchaPreAuthenticationProviderTest.php:106
CaptchaPreAuthenticationProviderTest\provideGetAuthenticationRequests
provideGetAuthenticationRequests()
Definition: CaptchaPreAuthenticationProviderTest.php:68
CaptchaPreAuthenticationProviderTest\testTestForAccountCreation
testTestForAccountCreation( $req, $creator, $result, $disableTrigger=false)
provideTestForAccountCreation
Definition: CaptchaPreAuthenticationProviderTest.php:147
MediaWikiTestCase\setMwGlobals
setMwGlobals( $pairs, $value=null)
Definition: MediaWikiTestCase.php:658
MediaWikiTestCase
Definition: MediaWikiTestCase.php:13
CaptchaPreAuthenticationProviderTest\flagSession
flagSession()
Definition: CaptchaPreAuthenticationProviderTest.php:285
CaptchaPreAuthenticationProviderTest\testPostAuthentication
testPostAuthentication()
Definition: CaptchaPreAuthenticationProviderTest.php:176
MediaWiki
A helper class for throttling authentication attempts.
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
MediaWiki\Auth\UsernameAuthenticationRequest
AuthenticationRequest to ensure something with a username is present.
Definition: UsernameAuthenticationRequest.php:29
CaptchaPreAuthenticationProvider
Definition: CaptchaPreAuthenticationProvider.php:9
$services
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title after the basic globals have been set but before ordinary actions take place or wrap services the preferred way to define a new service is the $wgServiceWiringFiles array $services
Definition: hooks.txt:2179
any
they could even be mouse clicks or menu items whatever suits your program You should also get your if any
Definition: COPYING.txt:326
CaptchaPreAuthenticationProviderTest\testPingLimiter
testPingLimiter(array $attempts)
providePingLimiter
Definition: CaptchaPreAuthenticationProviderTest.php:219
SimpleCaptcha
Demo CAPTCHA (not for production usage) and base class for real CAPTCHAs.
Definition: Captcha.php:9
RequestContext\getMain
static getMain()
Static methods.
Definition: RequestContext.php:468
CaptchaPreAuthenticationProviderTest\blockLogin
blockLogin( $username)
Definition: CaptchaPreAuthenticationProviderTest.php:280
MediaWiki\Auth\AuthManager
This serves as the entry point to the authentication system.
Definition: AuthManager.php:82
CaptchaPreAuthenticationProviderTest\getCaptchaRequest
getCaptchaRequest( $id, $word, $username=null)
Definition: CaptchaPreAuthenticationProviderTest.php:273
CaptchaPreAuthenticationProviderTest\providePingLimiter
providePingLimiter()
Definition: CaptchaPreAuthenticationProviderTest.php:250
CaptchaPreAuthenticationProviderTest\testPostAuthentication_disabled
testPostAuthentication_disabled()
Definition: CaptchaPreAuthenticationProviderTest.php:199
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
true
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
Definition: hooks.txt:1956
wfMessage
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 default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "&lt
class
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
Definition: maintenance.txt:52
CaptchaPreAuthenticationProviderTest
Database.
Definition: CaptchaPreAuthenticationProviderTest.php:10
MediaWikiTestCase\setService
setService( $name, $object)
Sets a service, maintaining a stashed version of the previous service to be restored in tearDown.
Definition: MediaWikiTestCase.php:608
$username
this hook is for auditing only or null if authentication failed before getting that far $username
Definition: hooks.txt:783
CaptchaPreAuthenticationProviderTest\setTriggers
setTriggers( $triggers)
Definition: CaptchaPreAuthenticationProviderTest.php:290
array
the array() calling protocol came about after MediaWiki 1.4rc1.
CaptchaAuthenticationRequest
Generic captcha authentication request class.
Definition: CaptchaAuthenticationRequest.php:10
CaptchaPreAuthenticationProviderTest\setUp
setUp()
Definition: CaptchaPreAuthenticationProviderTest.php:11