Skip to content

Commit

Permalink
Renamed rate limit variables to follow convention
Browse files Browse the repository at this point in the history
  • Loading branch information
jeppekroghitk committed May 28, 2024
1 parent 139a9b8 commit 89258e2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions app/Core/Middleware/RequestRateLimiter.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,27 +50,27 @@ public function __construct()
public function handle(IncomingRequest $request, Closure $next): Response
{
//Configurable rate limits
$LEAN_RATELIMIT_GENERAL = app()->make(Environment::class)->get('LEAN_RATELIMIT_GENERAL') ?? 1000;
$LEAN_RATELIMIT_API = app()->make(Environment::class)->get('LEAN_RATELIMIT_API') ?? 10;
$LEAN_RATELIMIT_AUTH = app()->make(Environment::class)->get('LEAN_RATELIMIT_AUTH') ?? 20;
$rateLimitGeneral = app()->make(Environment::class)->get('LEAN_RATELIMIT_GENERAL') ?? 1000;
$rateLimitApi = app()->make(Environment::class)->get('LEAN_RATELIMIT_API') ?? 10;
$rateLimitAuth = app()->make(Environment::class)->get('LEAN_RATELIMIT_AUTH') ?? 20;

//Key
$key = $request->getClientIp();

//General Limit per minute
$limit = $LEAN_RATELIMIT_GENERAL;
$limit = $rateLimitGeneral;

//API Routes Limit
if ($request instanceof ApiRequest) {
$apiKey = "";
$key = app()->make(Api::class)->getAPIKeyUser($apiKey);
$limit = $LEAN_RATELIMIT_API;
$limit = $rateLimitApi;
}

$route = Frontcontroller::getCurrentRoute();

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

Expand Down

0 comments on commit 89258e2

Please sign in to comment.