Git Product home page Git Product logo

yesauthority's Introduction

YesAuthority


YesAuthority is flexible authorization system for Laravel, It checks the route permission to access a certain portion of the site or application. To add Permissions User-based, Role-based, Conditionally. It uses authority.checkpost middleware for filter permission of current accessing route, Under this middleware checked every permission of the user login.

Installation

Require this package in your composer.json or install it by running:

    composer require livelyworks/laravel-yes-authority

Now, insert this line into your config/app.php under the provider array.

    LivelyWorks\YesAuthority\YesAuthorityServiceProvider::class

Now, run this command after that config/yes-authority.php and app/Http/Middleware/YesAuthorityCheckpostMiddleware.php files are publish.

    php artisan vendor:publish  --tag="yesauthority"

Now, insert this line into your app/Http/Kernel.php under the $routeMiddleware array.

    'authority.checkpost'  => \App\Http\Middleware\YesAuthorityCheckpostMiddleware::class

Use authority.checkpost middleware for handle permission base routes.

    Route::group(['middleware' => 'authority.checkpost'], function () {
        // Place all those routes here which needs authentication and authorization.
    });

Now, the basic setup is ready you need to configure rules of permissions using config/yes-authority.

Configuration

The structure of permissions given below, but it's highly recommended to read more on docs`.

    [
        'allow' => ['*'], // Allowed permission to user. Priority is less than deny.
        'deny'  => ['temp1'], // Deny permission to user. Priority is higher than allow.
    ]

    canAccess('temp1');
    // false 

Usage - Helpers

  • canAccess($accessId = null);
    Check the access, By default it check current route and return response in boolean value.
    canAccess('temp1');
    // true or false
  • canPublicAccess($accessId = null); - Authentication not required
    Check the public access, By default it check current route and return response in boolean value.
    canPublicAccess();
    // true or false

Usage - Facade

  • YesAuthority::check($accessId = null, $requestForUserId = null)
    Check the access of $accessId, By default it check current route and return response in boolean value, And it can check access of perticular user by passing user id ($requestForUserId) parameter.
    YesAuthority::check('temp1');
    // true or false
  • YesAuthority::isPublicAccess($accessId = null); - Authentication not required
    Check the access of $accessId, By default it check current route and return response in boolean value.
    YesAuthority::isPublicAccess('temp1');
    // true or false

Usage - Directives

  • @canAccess($accessId = null);
    Check the access, By default it check current route and return response in boolean value.
    @canAccess()
       // your logic here.
    @endAccess;
  • @canPublicAccess($accessId = null); - Authentication not required
    Check the public access, By default it check current route and return response in boolean value.
    @canPublicAccess()
       // your logic here.
    @endAccess;

yesauthority's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.