5

关于 RBAC 设计优化的问题

 2 years ago
source link: https://www.v2ex.com/t/801787
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

V2EX  ›  数据库

关于 RBAC 设计优化的问题

  LotteWong · 1 天前 · 816 次点击

采用常见的五表法实现 RBAC 模块( user 、role 、permission 、user-role 、role-permission ),leader 表示每次鉴权都要:user → user-role → role → role-permission → permission,这样做的复杂度略高。现在想了两种方案优化:

  1. 联表查询。存在的问题:因为这个 RBAC 模块同时需要适配 MySQL 和 MongoDB,MySQL 还好处理,MongoDB 的聚合查询有点复杂而且性能不佳。
  2. 加新的表 user-permission 。存在的问题:当用户绑定角色 or 角色绑定权限时,每次都要更新 user-permission 表,写的消耗很大,而且有很多的冗余数据。

请问 uu 们有没有其它更好的优化方法呀?


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK