Laravel security router

Você é desenvolvedor  e gostaria de uma forma de proteger seu pacote para que outras pessoas somente configure as permissões e o nome das middleware?

Este pacote foi feito para você, assista ao vídeo ou leia leia o texto abaixo, o vídeo tem mais detalhes, vale a pena conferir.

https://github.com/resultsystems/laravel-security-router

Recomendável utilizar o artesaos/defender para que todas as funcionalidades possam serem aproveitadas.

Security Router – Service

Readme em Português.

Installation

1. Dependency

Using composer, execute the following command to automatically update your composer.json:

composer require resultsystems/laravel-security-router

or manually update your composer.json file

{
    "require": {
        "resultsystems/laravel-security-router": "1.*"
    }
}

2. Provider

You need to update your application configuration in order to register the package, so it can be loaded by Laravel. Just update your config/app.php file adding the following code at the end of your'providers' section:

// file START ommited
    'providers' => [
        // other providers ommited
        'ResultSystems\SecurityRouter\Providers\SecurityRouterServiceProvider',
    ],
// file END ommited

Made use:

Create your config file config/PACOTE.php

Exemple:

    'security'     => [
        'create'     =>   [
            'protected'  =>  false,
            'middleware' =>  [],
            'defender'   =>   [
                'load'       =>  true,
                'middleware' =>  ['sua-middware'],
                'can'        =>  ['product.create','product.store'],
                'any'        =>  true,
                'is'         =>  null,
            ],
         ],
        'store'     =>   [
            'protected'  =>  false,
            'middleware' =>  [],
            'defender'   =>   [
                'load'       =>  true,
                'middleware' =>  ['sua-middware'],
                'can'        =>  ['product.store'],
                'any'        =>  false,
                'is'         =>  null,
            ],
         ],
    ],

Use:

$security=$this->app['security.router'];

$security=$security
    ->setFixedSecurity(['as'=>'index'])
    ->getConfig('storehouse-product', 'create');

Router::get('/product/create', $security,function (){
    retunr 'Eu estou protegido';
});
$security=$this->app['security.router'];

$security=$security
    ->setFixedSecurity(['as'=>'index'])
    ->getConfig('storehouse-product', 'create');

Router::get('/product/create', $security,function (){
    return 'Eu estou protegido';
});

$security=$security
    ->setFixedSecurity(['as'=>'store'])
    ->getConfig('storehouse-product', 'store');

Router::post('product', $security,function (){
    return 'Eu estou protegido';
});

$security=$security
    ->setFixedSecurity(['as'=>'store','Uses'=>'Controller@update'])
    ->getConfig('storehouse-product', 'update');

Router::put('product/{id}', $security)->where('id', '[0-9]+');