2016-04-25 20:58:18 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use MediaWiki\Auth\AuthManager;
|
|
|
|
use MediaWiki\Auth\UsernameAuthenticationRequest;
|
2022-04-08 16:40:15 +00:00
|
|
|
use MediaWiki\Extension\ConfirmEdit\Auth\CaptchaAuthenticationRequest;
|
|
|
|
use MediaWiki\Extension\ConfirmEdit\Auth\CaptchaPreAuthenticationProvider;
|
2023-08-23 22:52:30 +00:00
|
|
|
use MediaWiki\Extension\ConfirmEdit\Auth\LoginAttemptCounter;
|
2022-04-08 16:40:15 +00:00
|
|
|
use MediaWiki\Extension\ConfirmEdit\Hooks;
|
|
|
|
use MediaWiki\Extension\ConfirmEdit\SimpleCaptcha\SimpleCaptcha;
|
|
|
|
use MediaWiki\Extension\ConfirmEdit\Store\CaptchaHashStore;
|
|
|
|
use MediaWiki\Extension\ConfirmEdit\Store\CaptchaStore;
|
2023-05-19 10:23:59 +00:00
|
|
|
use MediaWiki\Request\FauxRequest;
|
2021-05-06 16:25:34 +00:00
|
|
|
use MediaWiki\Tests\Unit\Auth\AuthenticationProviderTestTrait;
|
2023-12-10 23:07:55 +00:00
|
|
|
use MediaWiki\User\User;
|
2017-04-19 21:41:46 +00:00
|
|
|
use Wikimedia\TestingAccessWrapper;
|
2016-04-25 20:58:18 +00:00
|
|
|
|
|
|
|
/**
|
2022-04-08 16:40:15 +00:00
|
|
|
* @covers \MediaWiki\Extension\ConfirmEdit\Auth\CaptchaPreAuthenticationProvider
|
2016-04-25 20:58:18 +00:00
|
|
|
* @group Database
|
|
|
|
*/
|
2021-05-06 16:25:34 +00:00
|
|
|
class CaptchaPreAuthenticationProviderTest extends MediaWikiIntegrationTestCase {
|
|
|
|
use AuthenticationProviderTestTrait;
|
|
|
|
|
2021-07-22 06:38:52 +00:00
|
|
|
public function setUp(): void {
|
2016-04-25 20:58:18 +00:00
|
|
|
parent::setUp();
|
|
|
|
$this->setMwGlobals( [
|
|
|
|
'wgCaptchaClass' => SimpleCaptcha::class,
|
|
|
|
'wgCaptchaBadLoginAttempts' => 1,
|
|
|
|
'wgCaptchaBadLoginPerUserAttempts' => 1,
|
|
|
|
'wgCaptchaStorageClass' => CaptchaHashStore::class,
|
|
|
|
] );
|
2016-07-28 13:51:51 +00:00
|
|
|
CaptchaStore::unsetInstanceForTests();
|
2016-04-25 20:58:18 +00:00
|
|
|
CaptchaStore::get()->clearAll();
|
|
|
|
}
|
|
|
|
|
2021-07-22 06:38:52 +00:00
|
|
|
public function tearDown(): void {
|
2016-04-25 20:58:18 +00:00
|
|
|
parent::tearDown();
|
|
|
|
// make sure $wgCaptcha resets between tests
|
2022-04-08 16:40:15 +00:00
|
|
|
TestingAccessWrapper::newFromClass( Hooks::class )->instanceCreated = false;
|
2016-04-25 20:58:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider provideGetAuthenticationRequests
|
|
|
|
*/
|
|
|
|
public function testGetAuthenticationRequests(
|
2023-08-18 14:32:35 +00:00
|
|
|
$action, $useExistingUserOrNull, $triggers, $needsCaptcha, $preTestCallback = null
|
2016-04-25 20:58:18 +00:00
|
|
|
) {
|
2023-08-18 14:32:35 +00:00
|
|
|
if ( $useExistingUserOrNull === true ) {
|
|
|
|
$username = $this->getTestSysop()->getUserIdentity()->getName();
|
|
|
|
} elseif ( $useExistingUserOrNull === false ) {
|
|
|
|
$username = 'Foo';
|
|
|
|
} else {
|
|
|
|
$username = null;
|
|
|
|
}
|
2016-04-25 20:58:18 +00:00
|
|
|
$this->setTriggers( $triggers );
|
|
|
|
if ( $preTestCallback ) {
|
|
|
|
$fn = array_shift( $preTestCallback );
|
|
|
|
call_user_func_array( [ $this, $fn ], $preTestCallback );
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @var FauxRequest $request */
|
|
|
|
$request = RequestContext::getMain()->getRequest();
|
|
|
|
$request->setCookie( 'UserName', $username );
|
|
|
|
|
|
|
|
$provider = new CaptchaPreAuthenticationProvider();
|
2021-05-06 16:25:34 +00:00
|
|
|
$this->initProvider( $provider, null, null, $this->getServiceContainer()->getAuthManager() );
|
2016-04-25 20:58:18 +00:00
|
|
|
$reqs = $provider->getAuthenticationRequests( $action, [ 'username' => $username ] );
|
|
|
|
if ( $needsCaptcha ) {
|
|
|
|
$this->assertCount( 1, $reqs );
|
|
|
|
$this->assertInstanceOf( CaptchaAuthenticationRequest::class, $reqs[0] );
|
|
|
|
} else {
|
2022-11-24 22:02:46 +00:00
|
|
|
$this->assertSame( [], $reqs );
|
2016-04-25 20:58:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-20 09:59:50 +00:00
|
|
|
public static function provideGetAuthenticationRequests() {
|
2016-04-25 20:58:18 +00:00
|
|
|
return [
|
|
|
|
[ AuthManager::ACTION_LOGIN, null, [], false ],
|
|
|
|
[ AuthManager::ACTION_LOGIN, null, [ 'badlogin' ], false ],
|
|
|
|
[ AuthManager::ACTION_LOGIN, null, [ 'badlogin' ], true, [ 'blockLogin', 'Foo' ] ],
|
|
|
|
[ AuthManager::ACTION_LOGIN, null, [ 'badloginperuser' ], false, [ 'blockLogin', 'Foo' ] ],
|
2023-08-18 14:32:35 +00:00
|
|
|
[ AuthManager::ACTION_LOGIN, false, [ 'badloginperuser' ], false, [ 'blockLogin', 'Bar' ] ],
|
|
|
|
[ AuthManager::ACTION_LOGIN, false, [ 'badloginperuser' ], true, [ 'blockLogin', 'Foo' ] ],
|
2016-04-25 20:58:18 +00:00
|
|
|
[ AuthManager::ACTION_LOGIN, null, [ 'badloginperuser' ], true, [ 'flagSession' ] ],
|
|
|
|
[ AuthManager::ACTION_CREATE, null, [], false ],
|
|
|
|
[ AuthManager::ACTION_CREATE, null, [ 'createaccount' ], true ],
|
2023-08-18 14:32:35 +00:00
|
|
|
[ AuthManager::ACTION_CREATE, true, [ 'createaccount' ], false ],
|
2016-04-25 20:58:18 +00:00
|
|
|
[ AuthManager::ACTION_LINK, null, [], false ],
|
|
|
|
[ AuthManager::ACTION_CHANGE, null, [], false ],
|
|
|
|
[ AuthManager::ACTION_REMOVE, null, [], false ],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetAuthenticationRequests_store() {
|
|
|
|
$this->setTriggers( [ 'createaccount' ] );
|
|
|
|
$captcha = new SimpleCaptcha();
|
|
|
|
$provider = new CaptchaPreAuthenticationProvider();
|
2021-05-06 16:25:34 +00:00
|
|
|
$this->initProvider( $provider, null, null, $this->getServiceContainer()->getAuthManager() );
|
2016-04-25 20:58:18 +00:00
|
|
|
|
|
|
|
$reqs = $provider->getAuthenticationRequests( AuthManager::ACTION_CREATE,
|
|
|
|
[ 'username' => 'Foo' ] );
|
|
|
|
|
|
|
|
$this->assertCount( 1, $reqs );
|
|
|
|
$this->assertInstanceOf( CaptchaAuthenticationRequest::class, $reqs[0] );
|
|
|
|
|
|
|
|
$id = $reqs[0]->captchaId;
|
|
|
|
$data = TestingAccessWrapper::newFromObject( $reqs[0] )->captchaData;
|
|
|
|
$this->assertEquals( $captcha->retrieveCaptcha( $id ), $data + [ 'index' => $id ] );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider provideTestForAuthentication
|
|
|
|
*/
|
|
|
|
public function testTestForAuthentication( $req, $isBadLoginTriggered,
|
|
|
|
$isBadLoginPerUserTriggered, $result
|
|
|
|
) {
|
2021-05-03 07:10:28 +00:00
|
|
|
$this->setTemporaryHook( 'PingLimiter', static function ( $user, $action, &$result ) {
|
2016-04-25 20:58:18 +00:00
|
|
|
$result = false;
|
|
|
|
return false;
|
|
|
|
} );
|
|
|
|
CaptchaStore::get()->store( '345', [ 'question' => '2+2', 'answer' => '4' ] );
|
2023-08-23 22:52:30 +00:00
|
|
|
$loginAttemptCounter = $this->getMockBuilder( LoginAttemptCounter::class )
|
2021-05-03 07:10:28 +00:00
|
|
|
->onlyMethods( [ 'isBadLoginTriggered', 'isBadLoginPerUserTriggered' ] )
|
2023-08-23 22:52:30 +00:00
|
|
|
->disableOriginalConstructor()
|
2019-10-22 04:52:40 +00:00
|
|
|
->getMock();
|
2023-08-23 22:52:30 +00:00
|
|
|
$loginAttemptCounter->expects( $this->any() )->method( 'isBadLoginTriggered' )
|
2016-04-25 20:58:18 +00:00
|
|
|
->willReturn( $isBadLoginTriggered );
|
2023-08-23 22:52:30 +00:00
|
|
|
$loginAttemptCounter->expects( $this->any() )->method( 'isBadLoginPerUserTriggered' )
|
2016-04-25 20:58:18 +00:00
|
|
|
->willReturn( $isBadLoginPerUserTriggered );
|
2023-08-23 22:52:30 +00:00
|
|
|
$provider = $this->getProvider();
|
|
|
|
$provider->loginAttemptCounter = $loginAttemptCounter;
|
2021-05-06 16:25:34 +00:00
|
|
|
$this->initProvider( $provider, null, null, $this->getServiceContainer()->getAuthManager() );
|
2016-04-25 20:58:18 +00:00
|
|
|
|
|
|
|
$status = $provider->testForAuthentication( $req ? [ $req ] : [] );
|
2023-08-23 22:52:30 +00:00
|
|
|
|
2016-04-25 20:58:18 +00:00
|
|
|
$this->assertEquals( $result, $status->isGood() );
|
|
|
|
}
|
|
|
|
|
2023-05-20 09:59:50 +00:00
|
|
|
public static function provideTestForAuthentication() {
|
2016-04-25 20:58:18 +00:00
|
|
|
$fallback = new UsernameAuthenticationRequest();
|
|
|
|
$fallback->username = 'Foo';
|
|
|
|
return [
|
|
|
|
// [ auth request, bad login?, bad login per user?, result ]
|
|
|
|
'no need to check' => [ $fallback, false, false, true ],
|
|
|
|
'badlogin' => [ $fallback, true, false, false ],
|
|
|
|
'badloginperuser, no username' => [ null, false, true, true ],
|
|
|
|
'badloginperuser' => [ $fallback, false, true, false ],
|
2023-05-20 09:59:50 +00:00
|
|
|
'non-existent captcha' => [ self::getCaptchaRequest( '123', '4' ), true, true, false ],
|
|
|
|
'wrong captcha' => [ self::getCaptchaRequest( '345', '6' ), true, true, false ],
|
|
|
|
'correct captcha' => [ self::getCaptchaRequest( '345', '4' ), true, true, true ],
|
2016-04-25 20:58:18 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider provideTestForAccountCreation
|
|
|
|
*/
|
2023-08-18 14:32:35 +00:00
|
|
|
public function testTestForAccountCreation( $req, $creatorIsSysop, $result, $disableTrigger = false ) {
|
2021-05-03 07:10:28 +00:00
|
|
|
$this->setTemporaryHook( 'PingLimiter', static function ( $user, $action, &$result ) {
|
2016-04-25 20:58:18 +00:00
|
|
|
$result = false;
|
|
|
|
return false;
|
|
|
|
} );
|
|
|
|
$this->setTriggers( $disableTrigger ? [] : [ 'createaccount' ] );
|
|
|
|
CaptchaStore::get()->store( '345', [ 'question' => '2+2', 'answer' => '4' ] );
|
|
|
|
$user = User::newFromName( 'Foo' );
|
|
|
|
$provider = new CaptchaPreAuthenticationProvider();
|
2021-05-06 16:25:34 +00:00
|
|
|
$this->initProvider( $provider, null, null, $this->getServiceContainer()->getAuthManager() );
|
2016-04-25 20:58:18 +00:00
|
|
|
|
2023-08-18 14:32:35 +00:00
|
|
|
$creator = $creatorIsSysop ? $this->getTestSysop()->getUser() : User::newFromName( 'Bar' );
|
2016-04-25 20:58:18 +00:00
|
|
|
$status = $provider->testForAccountCreation( $user, $creator, $req ? [ $req ] : [] );
|
|
|
|
$this->assertEquals( $result, $status->isGood() );
|
|
|
|
}
|
|
|
|
|
2023-05-20 09:59:50 +00:00
|
|
|
public static function provideTestForAccountCreation() {
|
2016-04-25 20:58:18 +00:00
|
|
|
return [
|
|
|
|
// [ auth request, creator, result, disable trigger? ]
|
2023-08-18 14:32:35 +00:00
|
|
|
'no captcha' => [ null, false, false ],
|
|
|
|
'non-existent captcha' => [ self::getCaptchaRequest( '123', '4' ), false, false ],
|
|
|
|
'wrong captcha' => [ self::getCaptchaRequest( '345', '6' ), false, false ],
|
|
|
|
'correct captcha' => [ self::getCaptchaRequest( '345', '4' ), false, true ],
|
|
|
|
'user is exempt' => [ null, true, true ],
|
|
|
|
'disabled' => [ null, false, true, 'disable' ],
|
2016-04-25 20:58:18 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testPostAuthentication() {
|
|
|
|
$this->setTriggers( [ 'badlogin', 'badloginperuser' ] );
|
|
|
|
$captcha = new SimpleCaptcha();
|
|
|
|
$user = User::newFromName( 'Foo' );
|
|
|
|
$anotherUser = User::newFromName( 'Bar' );
|
2023-08-23 22:52:30 +00:00
|
|
|
$provider = $this->getProvider();
|
|
|
|
$loginAttemptCounter = new LoginAttemptCounter( $captcha );
|
|
|
|
$provider->loginAttemptCounter = $loginAttemptCounter;
|
2021-05-06 16:25:34 +00:00
|
|
|
$this->initProvider( $provider, null, null, $this->getServiceContainer()->getAuthManager() );
|
2016-04-25 20:58:18 +00:00
|
|
|
|
2023-08-23 22:52:30 +00:00
|
|
|
$this->assertFalse( $loginAttemptCounter->isBadLoginTriggered() );
|
|
|
|
$this->assertFalse( $loginAttemptCounter->isBadLoginPerUserTriggered( $user ) );
|
2016-04-25 20:58:18 +00:00
|
|
|
|
|
|
|
$provider->postAuthentication( $user, \MediaWiki\Auth\AuthenticationResponse::newFail(
|
|
|
|
wfMessage( '?' ) ) );
|
|
|
|
|
2023-08-23 22:52:30 +00:00
|
|
|
$this->assertTrue( $loginAttemptCounter->isBadLoginTriggered() );
|
|
|
|
$this->assertTrue( $loginAttemptCounter->isBadLoginPerUserTriggered( $user ) );
|
|
|
|
$this->assertFalse( $loginAttemptCounter->isBadLoginPerUserTriggered( $anotherUser ) );
|
2016-04-25 20:58:18 +00:00
|
|
|
|
|
|
|
$provider->postAuthentication( $user, \MediaWiki\Auth\AuthenticationResponse::newPass( 'Foo' ) );
|
|
|
|
|
2023-08-23 22:52:30 +00:00
|
|
|
$this->assertFalse( $loginAttemptCounter->isBadLoginPerUserTriggered( $user ) );
|
2016-04-25 20:58:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testPostAuthentication_disabled() {
|
|
|
|
$this->setTriggers( [] );
|
|
|
|
$captcha = new SimpleCaptcha();
|
2023-08-23 22:52:30 +00:00
|
|
|
$loginAttemptCounter = new LoginAttemptCounter( $captcha );
|
2016-04-25 20:58:18 +00:00
|
|
|
$user = User::newFromName( 'Foo' );
|
2023-08-23 22:52:30 +00:00
|
|
|
$provider = $this->getProvider();
|
|
|
|
$provider->loginAttemptCounter = $loginAttemptCounter;
|
2021-05-06 16:25:34 +00:00
|
|
|
$this->initProvider( $provider, null, null, $this->getServiceContainer()->getAuthManager() );
|
2016-04-25 20:58:18 +00:00
|
|
|
|
2023-08-23 22:52:30 +00:00
|
|
|
$this->assertFalse( $loginAttemptCounter->isBadLoginTriggered() );
|
|
|
|
$this->assertFalse( $loginAttemptCounter->isBadLoginPerUserTriggered( $user ) );
|
2016-04-25 20:58:18 +00:00
|
|
|
|
|
|
|
$provider->postAuthentication( $user, \MediaWiki\Auth\AuthenticationResponse::newFail(
|
|
|
|
wfMessage( '?' ) ) );
|
|
|
|
|
2023-08-23 22:52:30 +00:00
|
|
|
$this->assertFalse( $loginAttemptCounter->isBadLoginTriggered() );
|
|
|
|
$this->assertFalse( $loginAttemptCounter->isBadLoginPerUserTriggered( $user ) );
|
2016-04-25 20:58:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider providePingLimiter
|
|
|
|
*/
|
|
|
|
public function testPingLimiter( array $attempts ) {
|
2016-10-04 05:33:27 +00:00
|
|
|
$this->mergeMwGlobalArrayValue(
|
|
|
|
'wgRateLimits',
|
|
|
|
[
|
|
|
|
'badcaptcha' => [
|
|
|
|
'user' => [ 1, 1 ],
|
|
|
|
],
|
|
|
|
]
|
|
|
|
);
|
2016-04-25 20:58:18 +00:00
|
|
|
$provider = new CaptchaPreAuthenticationProvider();
|
2021-05-06 16:25:34 +00:00
|
|
|
$this->initProvider( $provider, null, null, $this->getServiceContainer()->getAuthManager() );
|
2016-04-25 20:58:18 +00:00
|
|
|
$providerAccess = TestingAccessWrapper::newFromObject( $provider );
|
|
|
|
|
2020-04-02 19:19:22 +00:00
|
|
|
$disablePingLimiter = false;
|
|
|
|
$this->setTemporaryHook( 'PingLimiter',
|
2021-05-03 07:10:28 +00:00
|
|
|
static function ( &$user, $action, &$result ) use ( &$disablePingLimiter ) {
|
2020-04-02 19:19:22 +00:00
|
|
|
if ( $disablePingLimiter ) {
|
2016-04-25 20:58:18 +00:00
|
|
|
$result = false;
|
|
|
|
return false;
|
2020-04-02 19:19:22 +00:00
|
|
|
}
|
|
|
|
return null;
|
2016-04-25 20:58:18 +00:00
|
|
|
}
|
2020-04-02 19:19:22 +00:00
|
|
|
);
|
|
|
|
foreach ( $attempts as $attempt ) {
|
|
|
|
$disablePingLimiter = !empty( $attempts[3] );
|
2016-04-25 20:58:18 +00:00
|
|
|
$captcha = new SimpleCaptcha();
|
|
|
|
CaptchaStore::get()->store( '345', [ 'question' => '7+7', 'answer' => '14' ] );
|
|
|
|
$success = $providerAccess->verifyCaptcha( $captcha, [ $attempts[0] ], $attempts[1] );
|
|
|
|
$this->assertEquals( $attempts[2], $success );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-20 09:59:50 +00:00
|
|
|
public static function providePingLimiter() {
|
2016-04-25 20:58:18 +00:00
|
|
|
$sysop = User::newFromName( 'UTSysop' );
|
|
|
|
return [
|
|
|
|
// sequence of [ auth request, user, result, disable ping limiter? ]
|
|
|
|
'no failure' => [
|
2023-05-20 09:59:50 +00:00
|
|
|
[ self::getCaptchaRequest( '345', '14' ), new User(), true ],
|
|
|
|
[ self::getCaptchaRequest( '345', '14' ), new User(), true ],
|
2016-04-25 20:58:18 +00:00
|
|
|
],
|
|
|
|
'limited' => [
|
2023-05-20 09:59:50 +00:00
|
|
|
[ self::getCaptchaRequest( '345', '33' ), new User(), false ],
|
|
|
|
[ self::getCaptchaRequest( '345', '14' ), new User(), false ],
|
2016-04-25 20:58:18 +00:00
|
|
|
],
|
|
|
|
'exempt user' => [
|
2023-05-20 09:59:50 +00:00
|
|
|
[ self::getCaptchaRequest( '345', '33' ), $sysop, false ],
|
|
|
|
[ self::getCaptchaRequest( '345', '14' ), $sysop, true ],
|
2016-04-25 20:58:18 +00:00
|
|
|
],
|
|
|
|
'pinglimiter disabled' => [
|
2023-05-20 09:59:50 +00:00
|
|
|
[ self::getCaptchaRequest( '345', '33' ), new User(), false, 'disable' ],
|
|
|
|
[ self::getCaptchaRequest( '345', '14' ), new User(), true, 'disable' ],
|
2016-04-25 20:58:18 +00:00
|
|
|
],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2023-05-20 09:59:50 +00:00
|
|
|
protected static function getCaptchaRequest( $id, $word, $username = null ) {
|
2016-04-25 20:58:18 +00:00
|
|
|
$req = new CaptchaAuthenticationRequest( $id, [ 'question' => '?', 'answer' => $word ] );
|
|
|
|
$req->captchaWord = $word;
|
|
|
|
$req->username = $username;
|
|
|
|
return $req;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function blockLogin( $username ) {
|
2023-08-23 22:52:30 +00:00
|
|
|
$counter = new LoginAttemptCounter( new SimpleCaptcha() );
|
|
|
|
$counter->increaseBadLoginCounter( $username );
|
2016-04-25 20:58:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function flagSession() {
|
|
|
|
RequestContext::getMain()->getRequest()->getSession()
|
|
|
|
->set( 'ConfirmEdit:loginCaptchaPerUserTriggered', true );
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function setTriggers( $triggers ) {
|
|
|
|
$types = [ 'edit', 'create', 'sendemail', 'addurl', 'createaccount', 'badlogin',
|
|
|
|
'badloginperuser' ];
|
2021-05-03 07:10:28 +00:00
|
|
|
$captchaTriggers = array_combine( $types, array_map( static function ( $type ) use ( $triggers ) {
|
2016-04-25 20:58:18 +00:00
|
|
|
return in_array( $type, $triggers, true );
|
|
|
|
}, $types ) );
|
|
|
|
$this->setMwGlobals( 'wgCaptchaTriggers', $captchaTriggers );
|
|
|
|
}
|
|
|
|
|
2023-08-23 22:52:30 +00:00
|
|
|
private function getProvider(): CaptchaPreAuthenticationProvider {
|
|
|
|
return new class() extends CaptchaPreAuthenticationProvider {
|
|
|
|
public ?LoginAttemptCounter $loginAttemptCounter = null;
|
|
|
|
|
|
|
|
protected function getLoginAttemptCounter( SimpleCaptcha $captcha ): LoginAttemptCounter {
|
|
|
|
return $this->loginAttemptCounter ?: parent::getLoginAttemptCounter( $captcha );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2016-04-25 20:58:18 +00:00
|
|
|
}
|