2017 © Pedro Peláez
 

symfony-bundle request-limit-bundle

The bundle which provides a light way to restrict user access to some action for a specific time frame

image

sfh/request-limit-bundle

The bundle which provides a light way to restrict user access to some action for a specific time frame

  • Saturday, July 21, 2018
  • by NovikovViktor
  • Repository
  • 1 Watchers
  • 1 Stars
  • 6 Installations
  • HTML
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 500 % Grown

The README.md

SensioLabsInsight Build Status Scrutinizer Code Quality Maintainability, (*1)

RequestLimitBundle

This bundle is a simple solution to restrict user access to some controller for a specified timeline., (*2)

This functionality could be used for different cases when you need to: - prevent flood - pushing users of irrelevant data; - prevent a user from accessing the certain endpoint very often, etc., (*3)

Installation

1) Install package via:, (*4)

    composer require nw/request-limit-bundle

2) Register bundle :, (*5)

In app/AppKernel.php prior to Symfony version 4.0:, (*6)

public function registerBundles()
{
    $bundles = [
        // ... ,
        new NW\RequestLimitBundle\NWRequestLimitBundle()
    ];

    // ...
    return $bundles;
}

In config/bundles.php when Symfony version is 4.0 and higher, (*7)

return [
    //... other bundles
    NW\RequestLimitBundle\NWRequestLimitBundle::class => ['all' => true]
];

3) Configure the bundle according to the provider you would like to use. Out of the box, we provide the Memcached and MySQL providers. To see configuration options, see the docs below., (*8)

If you want to use other storage, you can implement your provider., (*9)

4) Specify restriction_time in seconds:, (*10)

nw_request_limit:
    #... options for provider configuration
    restriction_time: 5  # 5 seconds

Usage

In your action, add the following line to restrict access by some specific application user artifact (e.g., user id, user IP, etc.):, (*11)

$artifact = 'e.g. get user id or IP here';
$this->get('nw.request_limit.restrictor')->blockBy($artifact);

These will restrict user access for a time frame specified in your configuration (5 seconds accordingly to)., (*12)

The Versions

21/07 2018

dev-master

9999999-dev https://github.com/NovikovViktor/RequestLimitBundle

The bundle which provides a light way to restrict user access to some action for a specific time frame

  Sources   Download

MIT

The Requires

 

The Development Requires

by Viktor Novikov

symfony3 request post get http verbs restrict limitations