Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
eiixy committed Dec 11, 2020
2 parents fb55ede + ea6f114 commit c0c5ebd
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# laravel-rbac
> 基于laravel的后台权限管理拓展包
> 基于laravel的后台权限管理拓展包,精确到接口的权限管理
1. 使用 composer 安装
```bash
composer require sczts/laravel-rbac
Expand All @@ -11,26 +11,15 @@
php artisan vendor:publish --provider="Sczts\Rbac\Providers\RbacServiceProvider"
```

3. 修改配置文件 `config/rbac.php`
```base
/**
* 用户表名或模型
*/
3. 修改配置文件 `config/rbac.php` 填写实际的用户表名/模型,配置对应使用的auth中间件
```base=
'user' => 'users',
/**
* 权限中间件
*/
'middleware' => [
'api',
// 'jwt.auth',
// 'auth.api',
// 'auth:sanctum',
],
/**
* 角色组的权限/菜单缓存时间
*/
'cache_ttl' => 43200,
```

4. 进行数据库迁移
Expand All @@ -53,5 +42,16 @@
use Notifiable, UserPermission;
//......
```
7. 在路由中添加验证中间件 `rbac.check:{keyword}`
```php
// 示例代码:
Route::group(['prefix' => 'role', 'middleware' => ['api', 'auth:sanctum']], function () {
Route::get('/', 'RoleController@list')->middleware('rbac.check:sys_role.list');
Route::post('/', 'RoleController@store')->middleware('rbac.check:sys_role.add');
Route::get('/{id}', 'RoleController@show')->middleware('rbac.check:sys_role.show');
Route::put('/{id}', 'RoleController@update')->middleware('rbac.check:sys_role.update');
Route::delete('/{id}', 'RoleController@destroy')->middleware('rbac.check:sys_role.delete');
});
```

0 comments on commit c0c5ebd

Please sign in to comment.