diff --git a/.env.example b/.env.example index 28195caf..44ee8787 100644 --- a/.env.example +++ b/.env.example @@ -87,7 +87,3 @@ FORWARD_DB_PORT=54329 VITE_HOST_NAME=vite.solidtime.test VITE_APP_NAME="${APP_NAME}" #SAIL_XDEBUG_MODE=develop,debug,coverage - -# API rate limiting (requests per minute) -API_RATE_LIMIT_AUTH_PER_MINUTE=200 -API_RATE_LIMIT_GUEST_PER_MINUTE=60 diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 71fd556e..7ac8628a 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -33,8 +33,8 @@ class RouteServiceProvider extends ServiceProvider } return $request->user() - ? Limit::perMinute(config('services.api.authenticated'))->by($request->user()->id) - : Limit::perMinute(config('services.api.guest'))->by($request->ip()); + ? Limit::perMinute(config('app.api_rate_limit_authenticated_per_minute'))->by($request->user()->id) + : Limit::perMinute(config('app.api_rate_limit_guest_per_minute'))->by($request->ip()); }); $this->routes(function (): void { diff --git a/config/app.php b/config/app.php index 356fecf1..64d67991 100644 --- a/config/app.php +++ b/config/app.php @@ -158,6 +158,21 @@ return [ 'pagination_per_page_default' => (int) env('PAGINATION_PER_PAGE_DEFAULT', 15), + /* + |-------------------------------------------------------------------------- + | API Rate Limiting + |-------------------------------------------------------------------------- + | + | The number of API requests allowed per minute, counted per user for + | authenticated requests and per IP address for guest requests. These + | limits are only enforced when the application runs in production. + | + */ + + 'api_rate_limit_authenticated_per_minute' => (int) (env('API_RATE_LIMIT_AUTH_PER_MINUTE') ?: 200), + + 'api_rate_limit_guest_per_minute' => (int) (env('API_RATE_LIMIT_GUEST_PER_MINUTE') ?: 60), + /* |-------------------------------------------------------------------------- | Encryption Key diff --git a/config/services.php b/config/services.php index 5663a84b..57c8cdb7 100644 --- a/config/services.php +++ b/config/services.php @@ -8,8 +8,4 @@ return [ 'basic_auth_username' => env('GOTENBERG_BASIC_AUTH_USERNAME'), 'basic_auth_password' => env('GOTENBERG_BASIC_AUTH_PASSWORD'), ], - 'api' => [ - 'authenticated' => (int) env('API_RATE_LIMIT_AUTH_PER_MINUTE', 200), - 'guest' => (int) env('API_RATE_LIMIT_GUEST_PER_MINUTE', 60), - ], ];