2017 © Pedro Peláez
 

library throttle

Ban identifier after certain amount of requests in a given timeframe.

image

sideshow_bob/throttle

Ban identifier after certain amount of requests in a given timeframe.

  • Wednesday, February 17, 2016
  • by sideshow_bob
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1,573 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 11 Versions
  • 14 % Grown

The README.md

Throttle

Ban identifier after certain amount of requests in a given timeframe., (*1)

Build Status, (*2)

Installation

The suggested installation method is via composer:, (*3)

php composer.phar require "sideshow_bob/throttle"

Usage

Basic usage of the Throttle class to ban an identifier., (*4)


// ip $identifier = $_SERVER["REMOTE_ADDR"]; // instantiate class $throttle = new \sideshow_bob\Throttle(new \sideshow_bob\Storage\Memcached()); if($throttle->validate($identifier)) { // success proceed } else { // banned }

Storage

Included are Array, Memcached, Redis, Predis and doctrine/cache storage implementations, however it is very easy to use some other storage system just implement the StorageInterface and inject that object into the Throttle constructor., (*5)

Caution

Whatever storage system you decide to use, do not store the failed request data into your database, this could lead to a DDOS attack and take your database down., (*6)

Options

You can override the default options by instantiating a Throttle class and pass in an array as the third argument., (*7)

$options = [
    "ban" => 10,      // ban identifier after 10 attempts. (default 5)
    "log" => 20,      // log identifier after 20 attempts. (default 10)
    "timespan" => 60, // the timespan for the duration of the ban. (default 86400)
];

// Instantiate class
$throttle = new \sideshow_bob\Throttle(new \sideshow_bob\Storage\Memcached(), $options);

Logger

Any logger library that implements the PSR-3 LoggerInterface should work, just create your Logger object and inject it into the Throttle constructor. For example the excellent logging library Monolog., (*8)

Other Methods

reset()

This will remove the identifier from the storage., (*9)

$throttle->reset($identifier);

remaining()

This will return an integer that is the remaining attempt(s) available before identifier gets banned., (*10)

$throttle->remaining($identifier);

Testing

The test folder contains all tests., (*11)

Acknowledgement

Forked from websoftwares/throttle., (*12)

The Versions

17/02 2016

dev-master

9999999-dev

Ban identifier after certain amount of requests in a given timeframe.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar sideshow_bob

security login ip throttle rate limit brute force hammer

17/02 2016

0.4.3

0.4.3.0

Ban identifier after certain amount of requests in a given timeframe.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar sideshow_bob

security login ip throttle rate limit brute force hammer

17/02 2016

0.4.2

0.4.2.0

Ban identifier after certain amount of requests in a given timeframe.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar sideshow_bob

security login ip throttle rate limit brute force hammer

13/02 2016

0.4.1

0.4.1.0

Ban identifier after certain amount of requests in a given timeframe.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar sideshow_bob

security login ip throttle rate limit brute force hammer

13/02 2016

0.4.0

0.4.0.0

Ban identifier after certain amount of requests in a given timeframe.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar sideshow_bob

security login ip throttle rate limit brute force hammer

16/08 2013

0.3.3

0.3.3.0

Ban identifier after certain amount of requests in a given timeframe.

  Sources   Download

dbad

The Requires

 

The Development Requires

by Boris Verhaaff

security login ip throttle rate limit brute force hammer

15/08 2013

0.3.2

0.3.2.0

Ban identifier after certain amount of requests in a given timeframe.

  Sources   Download

dbad

The Requires

 

The Development Requires

by Boris Verhaaff

security login ip throttle rate limit brute force hammer

15/08 2013

0.3.1

0.3.1.0

Ban identifier after certain amount of requests in a given timeframe.

  Sources   Download

dbad

The Requires

 

The Development Requires

by Boris Verhaaff

security login ip throttle rate limit brute force hammer

15/08 2013

0.3

0.3.0.0

Ban identifier after certain amount of requests in a given timeframe.

  Sources   Download

dbad

The Requires

 

The Development Requires

by Boris Verhaaff

security login ip throttle rate limit brute force hammer

12/08 2013

0.2

0.2.0.0

Ban identifier after certain amount of requests in a given timeframe.

  Sources   Download

dbad

The Requires

 

The Development Requires

by Boris Verhaaff

security login ip throttle rate limit brute force hammer

08/08 2013

0.1

0.1.0.0

Ban ip-adress after certain amount of requests in a given timeframe.

  Sources   Download

dbad

The Requires

 

The Development Requires

by Boris Verhaaff

security login ip throttle rate limit brute force hammer