Superban is a Laravel package designed to enhance your application's rate-limiting capabilities by providing the ability to ban clients completely for a specified period of time. This package integrates seamlessly with Laravel's built-in rate limiting features and allows you to configure different cache drivers such as Redis, Database, etc.
To get started with Superban, simply install the package through Composer:
composer require edenlife/superban
In the superban.php
configuration file, you can:
- Specify Cache Driver:
- Choose the cache driver that Superban should use (e.g., Redis, Database).
- Set Ban Threshold:
- Configure the number of requests after which a client will be banned.
- Define Ban Duration:
- Specify the duration of the ban for a client after reaching the threshold.
- Choose Ban Criteria:
- Decide whether to ban by user ID, IP address, email, or a combination of these.
- Apply Bans Globally or Per Route:
- Choose whether to apply bans globally for all routes or specify particular routes.
To utilize Superban in your Laravel application, add the Superban middleware to the desired routes or apply it globally in your App\Http\Kernel
:
protected$middleware = [ // ... other middleware \Edenlife\Superban\Http\Middleware\SuperbanMiddleware::class, ];
Route::get('/protected-route', 'YourController@protectedAction')->middleware('superban');
If you encounter any issues or have suggestions for improvements, feel free to open an issue or submit a pull request on the GitHub repository.
Superban is open-sourced software licensed under the MIT license.