mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-20 22:22:16 +01:00
move api rate limit to app config, add fallback for empty env key
This commit is contained in:
@@ -87,7 +87,3 @@ FORWARD_DB_PORT=54329
|
|||||||
VITE_HOST_NAME=vite.solidtime.test
|
VITE_HOST_NAME=vite.solidtime.test
|
||||||
VITE_APP_NAME="${APP_NAME}"
|
VITE_APP_NAME="${APP_NAME}"
|
||||||
#SAIL_XDEBUG_MODE=develop,debug,coverage
|
#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
|
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ class RouteServiceProvider extends ServiceProvider
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $request->user()
|
return $request->user()
|
||||||
? Limit::perMinute(config('services.api.authenticated'))->by($request->user()->id)
|
? Limit::perMinute(config('app.api_rate_limit_authenticated_per_minute'))->by($request->user()->id)
|
||||||
: Limit::perMinute(config('services.api.guest'))->by($request->ip());
|
: Limit::perMinute(config('app.api_rate_limit_guest_per_minute'))->by($request->ip());
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->routes(function (): void {
|
$this->routes(function (): void {
|
||||||
|
|||||||
@@ -158,6 +158,21 @@ return [
|
|||||||
|
|
||||||
'pagination_per_page_default' => (int) env('PAGINATION_PER_PAGE_DEFAULT', 15),
|
'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
|
| Encryption Key
|
||||||
|
|||||||
@@ -8,8 +8,4 @@ return [
|
|||||||
'basic_auth_username' => env('GOTENBERG_BASIC_AUTH_USERNAME'),
|
'basic_auth_username' => env('GOTENBERG_BASIC_AUTH_USERNAME'),
|
||||||
'basic_auth_password' => env('GOTENBERG_BASIC_AUTH_PASSWORD'),
|
'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),
|
|
||||||
],
|
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user