Comments (2)
关于权限菜单这块。
抱歉,应该很长一段时间不会更新了,忙别的去了 ...
网上方案应该很多,我的思路大致就是基于 RBAC 设计,写个权限中间件(PermissionMiddleware.php)。
1.routes.php 可以再细分 登录需要验证权限的路由 和 登录不需要验证权限的路由(区别就是验证权限的额外增加PermissionMiddleware)。另外要注意顺序,先走auth中间件,再走permission中间件
2.PermissionMiddleware 里先通过 $request->getAttribute('hb_user'); 获取当前user , 也就能获取到对应的 role 从而进一步获取 对应的 permissions ,再进一步验证permissions 对当前路由比如 request的path 是否为包含关系
3.数据表描述:
建立 role表(这里一个角色对应一个role的方式举例),user表增加role_id字段;
建立 permission表(这里你就可以任意起名字,比如name字段是 用户查看权限, code字段为 user_view);
建立 role_permission_relate 表(一个角色有多个权限);
建立 access表 (这里记录所有 路由资源即:可访问的 url);
建立 permission_access_relate 表 (一个权限对应多个路由, 比如用户查看权限对应 admin/user/info, admin/user/list 等路由)
4.到此就应该知道大致验证流程了
from hyperfbase.
关闭 issue了哈
from hyperfbase.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hyperfbase.