andreyv/yii2-ip-ratelimiter 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

andreyv/yii2-ip-ratelimiter

最新稳定版本:2.3.1

Composer 安装命令:

composer require andreyv/yii2-ip-ratelimiter

包简介

Allow guest clients to be rate limited, using their IP as the identifier.

README 文档

README

Yii2 IP Rate Limiter

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 andreyv/yii2-ip-ratelimiter "2.*"

or add

"andreyv/yii2-ip-ratelimiter": "2.*"

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' => \andreyv\ratelimiter\IpRateLimiter::class,

        // 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 false
        // - false: use one set of rates, whether you are authenticated or not
        // - true: use separate ratesfor guests and authenticated users
        'separateRates' => true,

        // Whether to return HTTP headers containing the current rate limiting information
        'enableRateLimitHeaders' => false,

        // Array of actions on which to apply ratelimiter, if empty - applies to all actions
        'actions' => ['index'],

        // Allows to skip rate limiting for test environment
        'testMode' => true,
        // Defines whether proxy enabled, list of headers getting from request ipHeaders. By default ['X-Forwarded-For']
        'proxyEnabled' => false
    ];
    return $behaviors;
}

Forked from ethercreative/yii2-ip-ratelimiter.

统计信息

  • 总下载量: 58.86k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 0
  • Forks: 11
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-11-22