#基于数据的RBAC
适用于前后端分离项目的权限管理
树形菜单 角色管理 用户管理 API管理
Require this package with composer using the following command:
composer require lwj/laravel-rbac
After updating composer, add the service provider to the providers
array in config/app.php
Lwj\Rbac\ServiceProvider::class,
Laravel 5.5 uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider.
Add the middleware alias routeMiddleware
array in app/Http/Kernel.php
'jwt.auth' => \Tymon\JWTAuth\Http\Middleware\Authenticate::class,
'jwt.refresh' => \Tymon\JWTAuth\Http\Middleware\RefreshToken::class,
Generate the ENV option:
php artisan jwt:secret
You can also publish the config file to change implementations (ie. interface to specific class) or set defaults for --helpers
or --sublime
.
php artisan vendor:publish --provider="Lwj\Rbac\ServiceProvider" --tag=config
php artisan vendor:publish --provider="Lwj\Rbac\ServiceProvider" --tag=assets
php artisan vendor:publish --provider="Tymon\JWTAuth\Providers\LaravelServiceProvider"
Inside the config/auth.php file you will need to make a few changes to configure Laravel to use the jwt guard to power your application authentication.
Make the following changes to the file 'config/auth':
use Lwj\Rbac\Models\User;
And change the array:
'defaults' => [
'guard' => 'api',
'passwords' => 'users',
],
...
'guards' => [
...,
'api' => [
'driver' => 'token',
'provider' => 'users',
],
'rbac' => [
'driver' => 'jwt',
'provider' => 'users',
]
],
...
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => User::class,
],
],
You can also migrate tables and base data:
php artisan migrate
Default User:
name: [email protected]
password: 123456
'SUPER_ADMIN' env option to set super admin in this system: if you want to add new super admin,you can use '|' separator
进入docker之后 ln -sf /var/www/html/pay-php/service2/packages/laravel-rbac/public /var/www/html/pay-php/service2/public/vendor/rbac