livelyworks / laravel-yes-authority
YesAuthority - Laravel Routes Authorization Library
Installs: 1 584
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 4
Forks: 3
Open Issues: 0
Requires
- php: >=5.4.0
- laravel/framework: >=5.1
- livelyworks/laraware: >=1.2.6
- dev-master / 2.x-dev
- 2.9.16
- 2.9.15
- 2.9.14
- 2.9.12
- 2.9.11
- 2.9.10
- 2.9.9
- 2.9.8
- 2.9.7
- 2.9.6
- 2.9.5
- 2.9.3
- v2.9.1
- v2.9.0
- v2.8.0
- v2.7.8
- v2.7.7
- v2.7.6
- v2.7.5
- v2.7.2
- v2.7.1
- v2.7.0
- v2.6.1
- v2.6.0
- v2.5.0
- v2.3.2
- v2.3.1
- v2.3.0
- 2.1.8
- 2.1.7
- 2.1.5
- 2.1.4
- 2.1.3
- 2.1.2
- 2.1.1
- v2.1.0
- v2.0.7
- v2.0.6
- v2.0.5
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.0
- 1.20.21
- dev-2.x-dev
- dev-1.x-dev
This package is auto-updated.
Last update: 2024-10-28 22:06:11 UTC
README
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); -
Check the public access, By default it check current route and return response in boolean value.Authentication not required
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); -
Check the access ofAuthentication not required
$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); -
Check the public access, By default it check current route and return response in boolean value.Authentication not required
@canPublicAccess()
// your logic here.
@endAccess;