{"id":292,"date":"2015-07-03T15:54:23","date_gmt":"2015-07-03T18:54:23","guid":{"rendered":"http:\/\/www.henriquereis.com\/?p=292"},"modified":"2015-07-08T02:11:13","modified_gmt":"2015-07-08T05:11:13","slug":"laravel-security-router","status":"publish","type":"post","link":"https:\/\/henriquereis.com\/blog\/laravel-security-router\/","title":{"rendered":"Laravel security router"},"content":{"rendered":"<p>Voc\u00ea \u00e9 desenvolvedor \u00a0e gostaria de uma forma de proteger seu pacote para que outras pessoas somente configure as permiss\u00f5es e o nome das middleware?<\/p>\n<p>Este pacote foi feito para voc\u00ea, assista ao v\u00eddeo ou leia leia o texto abaixo, o v\u00eddeo tem mais detalhes, vale a pena conferir.<\/p>\n<div class=\"video-container\">\n<iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/mIkeYIXBrt8?rel=0\" frameborder=\"0\" allowfullscreen><\/iframe>\n<\/div>\n<p><a href=\"https:\/\/github.com\/resultsystems\/laravel-security-router\">https:\/\/github.com\/resultsystems\/laravel-security-router<\/a><\/p>\n<p>Recomend\u00e1vel utilizar o artesaos\/defender para que todas as funcionalidades possam serem aproveitadas.<\/p>\n<h1>Security Router &#8211; Service<\/h1>\n<p><a href=\"https:\/\/github.com\/resultsystems\/laravel-security-router\/blob\/master\/README-pt_BR.md\">Readme em Portugu\u00eas<\/a>.<\/p>\n<h2><a id=\"user-content-installation\" href=\"https:\/\/github.com\/resultsystems\/laravel-security-router#installation\"><\/a>Installation<\/h2>\n<h3><a id=\"user-content-1-dependency\" href=\"https:\/\/github.com\/resultsystems\/laravel-security-router#1-dependency\"><\/a>1. Dependency<\/h3>\n<p>Using\u00a0<a href=\"https:\/\/getcomposer.org\/\" target=\"_blank\">composer<\/a>, execute the following command to automatically update your\u00a0<code>composer.json<\/code>:<\/p>\n<div>\n<pre>composer require resultsystems\/laravel-security-router<\/pre>\n<\/div>\n<p>or manually update your\u00a0<code>composer.json<\/code>\u00a0file<\/p>\n<div>\n<pre>{\r\n    \"require\": {\r\n        \"resultsystems\/laravel-security-router\": \"1.*\"\r\n    }\r\n}<\/pre>\n<\/div>\n<h3><a id=\"user-content-2-provider\" href=\"https:\/\/github.com\/resultsystems\/laravel-security-router#2-provider\"><\/a>2. Provider<\/h3>\n<p>You need to update your application configuration in order to register the package, so it can be loaded by Laravel. Just update your\u00a0<code>config\/app.php<\/code>\u00a0file adding the following code at the end of your<code>'providers'<\/code>\u00a0section:<\/p>\n<div>\n<pre>\/\/ file START ommited\r\n    'providers' =&gt; [\r\n        \/\/ other providers ommited\r\n        'ResultSystems\\SecurityRouter\\Providers\\SecurityRouterServiceProvider',\r\n    ],\r\n\/\/ file END ommited<\/pre>\n<\/div>\n<h3><a id=\"user-content-made-use\" href=\"https:\/\/github.com\/resultsystems\/laravel-security-router#made-use\"><\/a>Made use:<\/h3>\n<p>Create your config file config\/PACOTE.php<\/p>\n<h4><a id=\"user-content-exemple\" href=\"https:\/\/github.com\/resultsystems\/laravel-security-router#exemple\"><\/a>Exemple:<\/h4>\n<div>\n<pre>    'security'     =&gt; [\r\n        'create'     =&gt;   [\r\n            'protected'  =&gt;  false,\r\n            'middleware' =&gt;  [],\r\n            'defender'   =&gt;   [\r\n                'load'       =&gt;  true,\r\n                'middleware' =&gt;  ['sua-middware'],\r\n                'can'        =&gt;  ['product.create','product.store'],\r\n                'any'        =&gt;  true,\r\n                'is'         =&gt;  null,\r\n            ],\r\n         ],\r\n        'store'     =&gt;   [\r\n            'protected'  =&gt;  false,\r\n            'middleware' =&gt;  [],\r\n            'defender'   =&gt;   [\r\n                'load'       =&gt;  true,\r\n                'middleware' =&gt;  ['sua-middware'],\r\n                'can'        =&gt;  ['product.store'],\r\n                'any'        =&gt;  false,\r\n                'is'         =&gt;  null,\r\n            ],\r\n         ],\r\n    ],<\/pre>\n<\/div>\n<h4><a id=\"user-content-use\" href=\"https:\/\/github.com\/resultsystems\/laravel-security-router#use\"><\/a>Use:<\/h4>\n<div>\n<pre>$security=$this-&gt;app['security.router'];\r\n\r\n$security=$security\r\n    -&gt;setFixedSecurity(['as'=&gt;'index'])\r\n    -&gt;getConfig('storehouse-product', 'create');\r\n\r\nRouter::get('\/product\/create', $security,function (){\r\n    retunr 'Eu estou protegido';\r\n});<\/pre>\n<pre>$security=$this-&gt;app['security.router'];\r\n\r\n$security=$security\r\n    -&gt;setFixedSecurity(['as'=&gt;'index'])\r\n    -&gt;getConfig('storehouse-product', 'create');\r\n\r\nRouter::get('\/product\/create', $security,function (){\r\n    return 'Eu estou protegido';\r\n});\r\n\r\n$security=$security\r\n    -&gt;setFixedSecurity(['as'=&gt;'store'])\r\n    -&gt;getConfig('storehouse-product', 'store');\r\n\r\nRouter::post('product', $security,function (){\r\n    return 'Eu estou protegido';\r\n});\r\n\r\n$security=$security\r\n    -&gt;setFixedSecurity(['as'=&gt;'store','Uses'=&gt;'Controller@update'])\r\n    -&gt;getConfig('storehouse-product', 'update');\r\n\r\nRouter::put('product\/{id}', $security)-&gt;where('id', '[0-9]+');<\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Voc\u00ea \u00e9 desenvolvedor \u00a0e gostaria de uma forma de proteger seu pacote para que outras pessoas somente configure as permiss\u00f5es e o nome das middleware? Este pacote foi feito para voc\u00ea, assista ao v\u00eddeo ou leia leia o texto abaixo, o v\u00eddeo tem mais detalhes, vale a pena conferir. https:\/\/github.com\/resultsystems\/laravel-security-router Recomend\u00e1vel utilizar o artesaos\/defender para &hellip; <a href=\"https:\/\/henriquereis.com\/blog\/laravel-security-router\/\" class=\"more-link\">Continue lendo <span class=\"screen-reader-text\">Laravel security router<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5],"tags":[],"_links":{"self":[{"href":"https:\/\/henriquereis.com\/blog\/wp-json\/wp\/v2\/posts\/292"}],"collection":[{"href":"https:\/\/henriquereis.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/henriquereis.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/henriquereis.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/henriquereis.com\/blog\/wp-json\/wp\/v2\/comments?post=292"}],"version-history":[{"count":6,"href":"https:\/\/henriquereis.com\/blog\/wp-json\/wp\/v2\/posts\/292\/revisions"}],"predecessor-version":[{"id":300,"href":"https:\/\/henriquereis.com\/blog\/wp-json\/wp\/v2\/posts\/292\/revisions\/300"}],"wp:attachment":[{"href":"https:\/\/henriquereis.com\/blog\/wp-json\/wp\/v2\/media?parent=292"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/henriquereis.com\/blog\/wp-json\/wp\/v2\/categories?post=292"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/henriquereis.com\/blog\/wp-json\/wp\/v2\/tags?post=292"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}