edenlife/superban

This package will add the ability to ban a client completely for a period of time

v1.1.1 2023-12-21 16:55 UTC

This package is auto-updated.

Last update: 2024-05-07 20:25:33 UTC


README

Overview

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.

Installation

To get started with Superban, simply install the package through Composer:

composer require edenlife/superban

Configuration

In the superban.php configuration file, you can:

  1. Specify Cache Driver:
    • Choose the cache driver that Superban should use (e.g., Redis, Database).
  2. Set Ban Threshold:
    • Configure the number of requests after which a client will be banned.
  3. Define Ban Duration:
    • Specify the duration of the ban for a client after reaching the threshold.
  4. Choose Ban Criteria:
    • Decide whether to ban by user ID, IP address, email, or a combination of these.
  5. Apply Bans Globally or Per Route:
    • Choose whether to apply bans globally for all routes or specify particular routes.

Usage

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
     \SuperBanHttp\Middleware\SuperbanMiddleware::class,
     ];

Example Middleware Usage

Route::get('/protected-route', 'YourController@protectedAction')->middleware('superban:10,2,10');

Contributing

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.

License

Superban is open-sourced software licensed under the MIT License.