juliocosta/lara-auth

There is no license information available for the latest version (dev-master) of this package.

Sanctum Auth ACL

dev-master 2020-06-09 02:07 UTC

This package is auto-updated.

Last update: 2024-05-09 11:48:25 UTC


README

Sacuntum Auth ACL is a Laravel package to authentication and authorization package.

The middleware has.acl check if auth user is authorized to access the route and he is authorized when has permission with the same name of the route within any role he has

Install

  • Install packaqe with composer composer require juliocosta/lara-auth
  • Publish seeder php artisan vendor:publish --force --tag auth-seeds
  • Add has.acl on routes with that you wish check permissions
  • Run php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider"
  • Run php artisan migrate
  • Run php artisan db:seed --class=PermissionsTableSeeder to populate permissions table

Use

  • Add Sanctum's middleware to your api middleware group within your app/Http/Kernel.php file:
    cUrl
use Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful;

'api' => [
    EnsureFrontendRequestsAreStateful::class,
    'throttle:60,1',
    \Illuminate\Routing\Middleware\SubstituteBindings::class,
],
  • Add trait in User model
use Laravel\Sanctum\HasApiTokens;

class User extends Authenticatable
{
    use HasApiTokens, Notifiable;
}