zeevx / superban
添加了禁止客户端在一段时间内完全访问你的应用路由的功能。
1.0.1
2023-12-22 12:12 UTC
Requires
- php: ^8.1
- illuminate/contracts: ^10.0
- spatie/laravel-package-tools: ^1.14.0
Requires (Dev)
- larastan/larastan: ^2.0.1
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.8
- orchestra/testbench: ^8.8
- pestphp/pest: ^2.20
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
README
Laravel Superban .
添加了禁止客户端在一段时间内完全访问你的应用路由的功能。
安装
您可以通过composer安装此包
composer require zeevx/superban
您可以使用以下命令发布配置文件
php artisan vendor:publish --tag="superban-config"
要使用中间件,请在app/Http/Kernel.php中添加它们
protected $routeMiddleware = [ 'superban' => \Zeevx\Superban\Middlewares\SuperbanMiddleware::class, ];
这是发布配置文件的内容
return [ /** * Key used in cache * The default is ip_address, you can use either: ip_address or email or user_id * */ 'key' => 'ip_address', /** * The cache to be used, * The default cache in config/cache.php is used if empty. */ 'cache' => 'file', /** * Specify guard to be used if you are using email or user_id * The default guard in config/auth.php is used if empty */ 'user_guard' => '', /** * Enable email notification for when a user is banned * */ 'enable_email_notification' => true, /** * Email address to be used for email notification * */ 'email_address' => '', ];
用法
将中间件应用到以下格式的任何路由
X - 请求次数
Y - 在多长时间内(分钟)
Z - 用户被禁止多长时间(分钟)。
Route::middleware(['superban:X,Y,Z])->group(function () { Route::post('/thisroute', function () { // ... }); Route::post('anotherroute', function () { // ... }); });
测试
composer test
致谢
许可
MIT许可(MIT)。请参阅许可文件获取更多信息。