From 0709b285d87503f4e3f5fc5352ed132921f15dd5 Mon Sep 17 00:00:00 2001 From: Dreamy Jazz Date: Tue, 22 Oct 2024 17:39:46 +0100 Subject: Add AuthenticationAttemptThrottled hook Why: * A hook is needed to allow extensions to run code when an authentication throttle causes throttling. ** This is so that we (T&S product) can monitor how many users are hitting the rate limits for temporary account creation on WMF wikis. What: * Add the AuthenticationAttemptThrottled hook, which is called from Throttle::increase when the method returns that the action should be throttled. * Update the tests for the class to verify the hook is called when it should be. Bug: T375500 Change-Id: I614ff6178d4a4f02b5c76d4b8818cb917c4d75aa --- includes/HookContainer/HookRunner.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'includes/HookContainer') diff --git a/includes/HookContainer/HookRunner.php b/includes/HookContainer/HookRunner.php index f002e936fc22..601b8a43848c 100644 --- a/includes/HookContainer/HookRunner.php +++ b/includes/HookContainer/HookRunner.php @@ -49,6 +49,7 @@ use WikiPage; */ class HookRunner implements \MediaWiki\Actions\Hook\GetActionNameHook, + \MediaWiki\Auth\Hook\AuthenticationAttemptThrottledHook, \MediaWiki\Auth\Hook\AuthManagerFilterProvidersHook, \MediaWiki\Auth\Hook\AuthManagerLoginAuthenticateAuditHook, \MediaWiki\Auth\Hook\AuthManagerVerifyAuthenticationHook, @@ -934,6 +935,12 @@ class HookRunner implements ); } + public function onAuthenticationAttemptThrottled( string $type, ?string $username, ?string $ip ) { + return $this->container->run( + 'AuthenticationAttemptThrottled', [ $type, $username, $ip ] + ); + } + public function onAutopromoteCondition( $type, $args, $user, &$result ) { return $this->container->run( 'AutopromoteCondition', -- cgit v1.2.3