2017 © Pedro Peláez
 

library antiflood

Request flood protection for laravel

image

ircop/antiflood

Request flood protection for laravel

  • Friday, July 28, 2017
  • by ircop
  • Repository
  • 1 Watchers
  • 13 Stars
  • 3,427 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 0 Open issues
  • 6 Versions
  • 81 % Grown

The README.md

Small antiflood system for Laravel

This tool designed for simple limiting some user requests. It makes it easy to add some protection from DB ddos or bruteforce attack., (*1)

INSTALL

1: install via composer, (*2)

composer require ircop/antiflood

2: add service provider to providers array in config/app.php:, (*3)

Ircop\Antiflood\AntifloodServiceProvider::class,

3: add facade alias to aliases array in config/app.php:, (*4)

'Antiflood' => Ircop\Antiflood\Facade\Antiflood::class,

Usage

Checking for record existance with given ident., (*5)

Ident can be ip-address, login, anything unique., (*6)

$maximum - is maximum allowed value for this ident. Default is 1., (*7)

\Antiflood::check( $ident, $maximum = 1 );

// Or with IP identity

\Antiflood::checkIP( $maximum = 1 );

Putting record for given ident on given $minutes:, (*8)

\Antiflood::put( $ident, $minutes = 10 );

// Or with IP identity

\Antiflood::putIP( $minutes = 10 );

Examples:

Limiting wrong login attempts for given IP address:

This example limiting wrong login attempts from one ip-address to 5 tryes per 20 minutes:, (*9)

public function postLogin()
{
    $key = $_SERVER['REMOTE_ADDR'];

    // If this ip has >= 5 failed login attempts in last 20 minutes, redirect user
    // back with error:
    if( \Antiflood::check( $key, 5 ) === FALSE )
        return redirect()->back()->withErrors(['Too many login attempts! Try again later.']);

    // ....
    // ....
    // ....

    // After failed login put user ipaddr to antiflood cacte on 20 min.
    // If there is no records with this ident, record will be added with value=1, else
    // it will be increased.
    \Antiflood::put( $key, 20 );
}

Limiting password recovery for 1 try per 30 min.

This code shows how to limit some functions like email, etc. to prevend flood from our server, for example., (*10)

public function postPasswordRecover()
{
    $key = \Input::get('email');
    if( \Antiflood::check( $key ) === FALSE )
        return redirect()->back()->withErrors(['.....']);

    // ....
    // ....
    // ....

    \Antiflood::put( $key, 20 );
}

The Versions

28/07 2017

dev-master

9999999-dev

Request flood protection for laravel

  Sources   Download

GPLv2

The Requires

 

by Avatar wingman

laravel spam flood antiflood

28/07 2017

v0.1.4

0.1.4.0

Request flood protection for laravel

  Sources   Download

GPLv2

The Requires

 

by Avatar wingman

laravel spam flood antiflood

28/01 2017

v0.1.3

0.1.3.0

Request flood protection for laravel

  Sources   Download

GPLv2

The Requires

 

by Avatar wingman

laravel spam flood antiflood

10/06 2016

v0.1.2

0.1.2.0

Request flood protection for laravel

  Sources   Download

GPLv2

The Requires

 

by Avatar wingman

laravel spam flood antiflood

12/11 2015

v0.1.1

0.1.1.0

Request flood protection for laravel

  Sources   Download

GPLv2

The Requires

 

by Avatar wingman

laravel spam flood antiflood

12/11 2015

v0.1

0.1.0.0

Request flood protection for laravel

  Sources   Download

GPLv2

The Requires

 

by Avatar wingman

laravel spam flood antiflood