From 6bc3e8e666b6d4ec16d999a8262c502655cc1ab3 Mon Sep 17 00:00:00 2001 From: Marcel Folaron Date: Tue, 11 Jun 2024 09:58:22 -0400 Subject: [PATCH] Add ratelimits to default config --- app/Core/DefaultConfig.php | 15 +++++++++++++++ app/Core/Middleware/RequestRateLimiter.php | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/Core/DefaultConfig.php b/app/Core/DefaultConfig.php index 07a1e1583..63aef6dea 100644 --- a/app/Core/DefaultConfig.php +++ b/app/Core/DefaultConfig.php @@ -476,4 +476,19 @@ class DefaultConfig * @var string trusted Proxies */ public string $trustedProxies = '127.0.0.1,REMOTE_ADDR'; + + /** + * @var int rate limit on all requests + */ + public int $ratelimitGeneral = 2000; + + /** + * @var int rate limit on api requests + */ + public int $ratelimitApi = 10; + + /** + * @var int rate limit on auth requests + */ + public int $rateLimitAuth = 20; } diff --git a/app/Core/Middleware/RequestRateLimiter.php b/app/Core/Middleware/RequestRateLimiter.php index 465bea7d3..b5813f6a8 100644 --- a/app/Core/Middleware/RequestRateLimiter.php +++ b/app/Core/Middleware/RequestRateLimiter.php @@ -88,7 +88,7 @@ public function handle(IncomingRequest $request, Closure $next): Response } $key = self::dispatch_filter( - "rateLimit", + "rateLimitKey", $key, [ "bootloader" => $this,