diff --git a/lib/private/AppFramework/Middleware/Security/RateLimitingMiddleware.php b/lib/private/AppFramework/Middleware/Security/RateLimitingMiddleware.php index de628bd9ca..38872c9ffc 100644 --- a/lib/private/AppFramework/Middleware/Security/RateLimitingMiddleware.php +++ b/lib/private/AppFramework/Middleware/Security/RateLimitingMiddleware.php @@ -114,8 +114,10 @@ class RateLimitingMiddleware extends Middleware { } else { $response = new TemplateResponse( 'core', - '429', - [], + '403', + [ + 'message' => $exception->getMessage(), + ], 'guest' ); $response->setStatus($exception->getCode()); diff --git a/lib/private/Security/Bruteforce/Throttler.php b/lib/private/Security/Bruteforce/Throttler.php index 1bece6a05d..d1a5f6d448 100644 --- a/lib/private/Security/Bruteforce/Throttler.php +++ b/lib/private/Security/Bruteforce/Throttler.php @@ -212,6 +212,10 @@ class Throttler { return 0; } + if ($ip === '') { + return 0; + } + $cutoffTime = (new \DateTime()) ->sub($this->getCutoff(43200)) ->getTimestamp(); diff --git a/tests/lib/AppFramework/Middleware/Security/RateLimitingMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/RateLimitingMiddlewareTest.php index 4e564f3eea..2804b8cd90 100644 --- a/tests/lib/AppFramework/Middleware/Security/RateLimitingMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/Security/RateLimitingMiddlewareTest.php @@ -270,8 +270,10 @@ class RateLimitingMiddlewareTest extends TestCase { $result = $this->rateLimitingMiddleware->afterException($controller, 'testMethod', new RateLimitExceededException()); $expected = new TemplateResponse( 'core', - '429', - [], + '403', + [ + 'message' => 'Rate limit exceeded', + ], 'guest' ); $expected->setStatus(429);