PHP code example of digbang / security

1. Go to this page and download the library: Download digbang/security library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

digbang / security example snippets


'providers' => [
    Digbang\Security\Laravel\SecurityServiceProvider::class,
];

 namespace App\Providers;

use Digbang\Security\SecurityContext;
use Digbang\Security\Configurations\SecurityContextConfiguration;

class MyServiceProvider extends \Illuminate\Support\ServiceProvider
{
    public function boot(SecurityContext $securityContext)
    {
        $configuration = new SecurityContextConfiguration('ecommerce');
        
        // customize the configuration object as needed...
        
        $securityContext->add($configuration);
    }
}


$router->group(['middleware' => 'security:ecommerce'], function(Router $router){
    
    // Controllers inside this routing group will be able to ask for an instance
    // of the Digbang\Security\Contracts\SecurityApi interface.
    
    $router->get('/', ['as' => 'foo', 'uses' => 'FooController@index']);
});

'global' => [
    'interval' => 900,
    'thresholds' => [
        10 => 1,
        20 => 2,
        30 => 4,
        40 => 8,
        50 => 16,
        60 => 12
    ]
],
'ip' => [
    'interval' => 900,
    'thresholds' => 5
],
'user' => [
    'interval' => 900,
    'thresholds' => 5
]