Giter Site home page Giter Site logo

yii2-ip-ratelimiter's Introduction

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 ethercreative/yii2-ip-ratelimiter "1.*"

or add

"ethercreative/yii2-ip-ratelimiter": "1.*"

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' => \ethercreative\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;
}

yii2-ip-ratelimiter's People

Contributors

alexjcollins avatar csharpru avatar xrymz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

yii2-ip-ratelimiter's Issues

User trait instead class

Hello, thanks for package.

What about idea, when logic of RateLimitInterface will be implemented in trait instead class.

I think it will be more flexible.

Installation via Composer issue

I have attempted to add this extension to my project but I am getting a composer error.

    - The requested package ethercreative/yii2-ip-ratelimiter ~2.0.0 exists as ethercreative/yii2-ip-ratelimiter[1.0, dev-master] but these are rejected by your constraint.

I have attempted to add this plugin via both ways
php composer.phar require ethercreative/yii2-ip-ratelimiter "~2.0.0"
Adding "ethercreative/yii2-ip-ratelimiter": "~2.0.0" to my composer.json

README.MD contains errors

php composer.phar require ethercreative/yii2-api-ratelimiter "~2.0.0"

should be:

php composer.phar require ethercreative/yii2-ip-ratelimiter "~1.0"

The package cannot be installed like this.

Question about timePeriod

Can you please describe what is the timePeriod (unit) property? Seconds or what?

I mean 1 min * X seconds?

Typo in README.md caused me problems installing

Under section Installation there is a typo in the suggested composer command...

php composer.phar require ethercretaive/yii2-ip-ratelimiter "~1.0.0"

vs

php composer.phar require ethercreative/yii2-ip-ratelimiter "~1.0.0"

Caused me a few minutes of confusion!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.