Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/emtudo/needsroleorpermission
Merge needsPermission and needsRoles artesaos/defender
https://github.com/emtudo/needsroleorpermission
Last synced: 11 days ago
JSON representation
Merge needsPermission and needsRoles artesaos/defender
- Host: GitHub
- URL: https://github.com/emtudo/needsroleorpermission
- Owner: emtudo
- License: mit
- Created: 2018-04-27T16:48:10.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-04-27T16:48:24.000Z (over 6 years ago)
- Last Synced: 2024-12-24T06:38:22.854Z (16 days ago)
- Language: PHP
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme-pt_BR.md
- License: LICENSE
Awesome Lists containing this project
README
#Junção dos middleware needsPermission e needsRoles do pacote artesaos/defender
[Readme on English](https://github.com/resultsystems/needsroleorpermission/blob/master/readme.md).
[artesaos/defender](https://github.com/artesaos/defender).
## Instalação
### 1. Dependência
Usando o composer, execute o comando a seguir para instalar automaticamente `composer.json`:
```shell
composer require resultsystems/needsroleorpermission
```ou manualmente no seu arquivo `composer.json`
```json
{
"require": {
"resultsystems/needsroleorpermission": "1.0.*"
}
}
```### 2. Middlewares
Para utilizá-los é necessário registrá-los no seu arquivo app/Http/Kernel.php.```php
protected $routeMiddleware = [
'auth' => 'App\Http\Middleware\Authenticate',
'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth',
'guest' => 'App\Http\Middleware\RedirectIfAuthenticated',// Controle de acesso usando permissões e grupos
'needsRoleOrPermission' => 'ResultSystems\NeedsRoleOrPermission\Http\Middleware\NeedsRoleOrPermission',
];
Route::get('foo', ['middleware' => ['auth', 'needsRoleOrPermission'], 'can' => ['user.index', 'user.create'], 'is' => 'admin', function()
{
return 'Sim eu posso!';
}]);
```