MediaWiki\Auth\Throttler: Change "ip" key name
authorBrad Jorsch <bjorsch@wikimedia.org>
Fri, 25 May 2018 18:50:55 +0000 (14:50 -0400)
committerBrad Jorsch <bjorsch@wikimedia.org>
Fri, 25 May 2018 19:55:19 +0000 (15:55 -0400)
Apparently 'ip' is overwritten by logstash at some level, so use 'ipKey'
instead.

Change-Id: I0547acdbb9f3fc7a990bd4baa2d748e89bac8c3b

includes/auth/Throttler.php
tests/phpunit/includes/auth/ThrottlerTest.php

index 3125bd3..717b592 100644 (file)
@@ -138,7 +138,7 @@ class Throttler implements LoggerAwareInterface {
                                $this->logRejection( [
                                        'throttle' => $this->type,
                                        'index' => $index,
-                                       'ip' => $ipKey,
+                                       'ipKey' => $ipKey,
                                        'username' => $username,
                                        'count' => $count,
                                        'expiry' => $expiry,
@@ -193,7 +193,7 @@ class Throttler implements LoggerAwareInterface {
 
        protected function logRejection( array $context ) {
                $logMsg = 'Throttle {throttle} hit, throttled for {expiry} seconds due to {count} attempts '
-                       . 'from username {username} and IP {ip}';
+                       . 'from username {username} and IP {ipKey}';
 
                // If we are hitting a throttle for >= warningLimit attempts, it is much more likely to be
                // an attack than someone simply forgetting their password, so log it at a higher level.
index f963ad9..12e8a49 100644 (file)
@@ -199,7 +199,7 @@ class ThrottlerTest extends \MediaWikiTestCase {
                $logger->expects( $this->once() )->method( 'log' )->with( $this->anything(), $this->anything(), [
                        'throttle' => 'custom',
                        'index' => 0,
-                       'ip' => '1.2.3.4',
+                       'ipKey' => '1.2.3.4',
                        'username' => 'SomeUser',
                        'count' => 1,
                        'expiry' => 10,