Download the PHP package davematics/superban without Composer
On this page you can find all versions of the php package davematics/superban. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download davematics/superban
More information about davematics/superban
Files in davematics/superban
Package superban
Short Description This package will add the ability to ban a client completely for a period of time
License
Informations about the package superban
Superban
The package features a middleware named "superban," allowing you to control user access within your application.
If a user makes excessive requests within a specific timeframe, the middleware will temporarily block the user and later unblock them.
Installation
You can install the package via Composer:
Manually add the service provider to the providers array in config/app.php:
After installation, publish the configuration file:
This will publish a superban.php file in your config directory.
Here you can Configure different cache drivers. - Redis, Database, etc.
USAGE
The middleware utilizes Laravel's RateLimiter class to track the number of attempts a user makes to access a resource within a specific time frame.
If the user surpasses the limit, the middleware generates a key based on the user's email, ID, or IP address and stores it in the cache for the designated time period. If the key is found in the cache, the middleware raises a UserBannedException.
Example
The "superban" middleware accepts three parameters:
The first parameter is the number of attempts a user can make before being banned.
The second parameter is number of minutes during which the user can attempt the route before facing a ban.
The last parameter is the number of minutes the user is banned.
On the route you can chnage the parameters 300, 5, 2880 based to fit in your specification.
Tests
To run the package tests, use the following bash command:
Security
If you find any security-related concerns, kindly reach out via email to: [email protected].