Skip to content

Commit

Permalink
[fix] ratelimit restrictions too low
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelfolaron committed May 25, 2024
1 parent b5ba975 commit c596342
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions app/Core/Middleware/RequestRateLimiter.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,15 @@ public function handle(IncomingRequest $request, Closure $next): Response
{

//Key
$key = $request->getClientIp();
$keyModifier = "-1";
if(isset($_SESSION['userdata'])){
$keyModifier = $_SESSION['userdata']['id'];
}

$key = $request->getClientIp()."-".$keyModifier;

//General Limit per minute
$limit = 1000;
$limit = 2000;

//API Routes Limit
if ($request instanceof ApiRequest) {
Expand All @@ -63,7 +68,7 @@ public function handle(IncomingRequest $request, Closure $next): Response
$route = Frontcontroller::getCurrentRoute();

if ($route == "auth.login") {
$limit = 20;
$limit = 50;
$key = $key . ".loginAttempts";
}

Expand Down

0 comments on commit c596342

Please sign in to comment.