2017 © Pedro Peláez
 

library permission-util

Provide a system to detect if the user connected have access or not. Provide a middleware to restrict access with a 403

image

distilleries/permission-util

Provide a system to detect if the user connected have access or not. Provide a middleware to restrict access with a 403

  • Monday, February 12, 2018
  • by Kezho
  • Repository
  • 4 Watchers
  • 3 Stars
  • 4,570 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 14 Versions
  • 5 % Grown

The README.md

Scrutinizer Code Quality Code Coverage Build Status Total Downloads Latest Stable Version License, (*1)

Laravel 5 Permission Util

Provide a system to detect if the user connected have access or not. Provide a middleware to restrict access with a 403, (*2)

Table of contents

  1. Installation
  2. Basic usage
  3. Middleware

Installation

Add on your composer.json, (*3)

``` json "require": { "distilleries/permission-util": "1.*", }, (*4)


run `composer update`. Add Service provider to `config/app.php`: ``` php 'providers' => [ // ... 'Distilleries\PermissionUtil\PermissionUtilServiceProvider', ]

And Facade (also in config/app.php), (*5)

``` php 'aliases' => [ // ... 'PermissionUtil' => 'Distilleries\PermissionUtil\Facades\PermissionUtil', ], (*6)



Export the configuration: ```ssh php artisan vendor:publish --provider="Distilleries\PermissionUtil\PermissionUtilProvider"

Basic usage

To check the permission, I use the auth of your application. On your model use for the Auth implement the interface Distilleries\PermissionUtil\Contracts\PermissionUtilContract add the method hasAccess to define if the user have access or not. The key in param is a string action like UserController@getEdit., (*7)

    public function hasAccess($key)
    {
        return true;
    }

If the user is connected and your model haven't this method the class return true. If the user is not connected the permission util return false. To disabled the restriction of connected user just go in config file and put false in auth_restricted., (*8)

You can use the facade to detect if the user can access or not:, (*9)

Method Call Description
hasAccess PermissionUtil::hasAccess('Controller@action') Return if the user can access to this action

Middleware

The package provide a middleware to detect automatically if the user can access to a method of a controller. To active it just add on your app/Http/Kernel:, (*10)

    protected $routeMiddleware = [
        //...
        'permission' => 'Distilleries\PermissionUtil\Http\Middleware\CheckAccessPermission',
    ];

And on your controller or your route add the middleware:, (*11)

    public function __construct()
    {
        $this->middleware('permission');

    }

If the user can access to an action that dispatch a 403, (*12)

The Versions

12/02 2018

dev-master

9999999-dev

Provide a system to detect if the user connected have access or not. Provide a middleware to restrict access with a 403

  Sources   Download

MIT

The Requires

 

The Development Requires

by Maxime Francois

12/02 2018

1.8.0

1.8.0.0

Provide a system to detect if the user connected have access or not. Provide a middleware to restrict access with a 403

  Sources   Download

MIT

The Requires

 

The Development Requires

by Maxime Francois

08/02 2018

1.7.0

1.7.0.0

Provide a system to detect if the user connected have access or not. Provide a middleware to restrict access with a 403

  Sources   Download

MIT

The Requires

 

The Development Requires

by Maxime Francois

23/02 2017

1.6.1

1.6.1.0

Provide a system to detect if the user connected have access or not. Provide a middleware to restrict access with a 403

  Sources   Download

MIT

The Requires

 

The Development Requires

by Maxime Francois

23/02 2017

1.6.0

1.6.0.0

Provide a system to detect if the user connected have access or not. Provide a middleware to restrict access with a 403

  Sources   Download

MIT

The Requires

 

The Development Requires

by Maxime Francois

15/09 2016

1.5.0

1.5.0.0

Provide a system to detect if the user connected have access or not. Provide a middleware to restrict access with a 403

  Sources   Download

MIT

The Requires

 

The Development Requires

by Maxime Francois

29/04 2016

1.4.0

1.4.0.0

Provide a system to detect if the user connected have access or not. Provide a middleware to restrict access with a 403

  Sources   Download

MIT

The Requires

 

The Development Requires

by Maxime Francois

15/01 2016

1.3.0

1.3.0.0

Provide a system to detect if the user connected have access or not. Provide a middleware to restrict access with a 403

  Sources   Download

MIT

The Requires

 

The Development Requires

by Maxime Francois

03/07 2015

dev-dev

dev-dev

Provide a system to detect if the user connected have access or not. Provide a middleware to restrict access with a 403

  Sources   Download

MIT

The Requires

 

The Development Requires

by Maxime Francois

03/07 2015

1.2.0

1.2.0.0

Provide a system to detect if the user connected have access or not. Provide a middleware to restrict access with a 403

  Sources   Download

MIT

The Requires

 

The Development Requires

by Maxime Francois

30/04 2015

1.1.2

1.1.2.0

Provide a system to detect if the user connected have access or not. Provide a middleware to restrict access with a 403

  Sources   Download

MIT

The Requires

 

The Development Requires

by Maxime Francois

03/03 2015

1.1.1

1.1.1.0

Provide a system to detect if the user connected have access or not. Provide a middleware to restrict access with a 403

  Sources   Download

MIT

The Requires

 

The Development Requires

by Maxime Francois

24/02 2015

1.1.0

1.1.0.0

Provide a system to detect if the user connected have access or not. Provide a middleware to restrict access with a 403

  Sources   Download

MIT

The Requires

 

The Development Requires

by Maxime Francois

20/02 2015

1.0.0

1.0.0.0

Provide a system to detect if the user connected have access or not. Provide a middleware to restrict access with a 403

  Sources   Download

MIT

The Requires

 

by Maxime Francois