uz / yii2-ip-ratelimiter
Allow guest clients to be rate limited, using their IP as the identifier.
Installs: 18
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 0
Open Issues: 0
Type:yii2-module
This package is not auto-updated.
Last update: 2024-11-18 14:32:20 UTC
README
yii2-ip-ratelimiter
Allow guest clients to be rate limited, using their IP as the identifier.
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require uz/yii2-ip-ratelimiter "^1.0"
or add
"uz/yii2-ip-ratelimiter": "^1.0"
to the require section of your composer.json
file.
Usage
Modify the bahavior method of the controller you want to rate limit
public function behaviors()
{
$behaviors = parent::behaviors();
$behaviors['rateLimiter'] = [
// Use class
'class' => \Mronx\ratelimiter\RateLimiter::className(),
// The maximum number of allowed requests
'rateLimit' => 100,
// The time period for the rates to apply to
'timePeriod' => 600,
// Separate rate limiting for guests and authenticated users
// Defaults to true
// - false: use one set of rates, whether you are authenticated or not
// - true: use separate ratesfor guests and authenticated users
'separateRates' => false,
// Whether to return HTTP headers containing the current rate limiting information
'enableRateLimitHeaders' => false,
];
return $behaviors;
}
Forked from ethercreative/yii2-ip-ratelimiter