Package Data | |
---|---|
Maintainer Username: | vinodraut |
Maintainer Contact: | vinod@livelyworks.net (Vinod Raut) |
Package Create Date: | 2017-07-26 |
Package Last Update: | 2023-02-28 |
Home Page: | https://livelyworks.github.io/YesAuthority/ |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-23 03:05:32 |
Package Statistics | |
---|---|
Total Downloads: | 1,583 |
Monthly Downloads: | 8 |
Daily Downloads: | 0 |
Total Stars: | 7 |
Total Watchers: | 4 |
Total Forks: | 3 |
Total Open Issues: | 0 |
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.
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
.
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
canAccess('temp1');
// true or false
Authentication not required
Check the public access, By default it check current route and return response in boolean value. canPublicAccess();
// true or false
$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
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
@canAccess()
// your logic here.
@endAccess;
Authentication not required
Check the public access, By default it check current route and return response in boolean value. @canPublicAccess()
// your logic here.
@endAccess;