Navigation Menu

Skip to content

caryl/bace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

== Welcome to RBACE ==

RBACE 目前是一个基于RBAC模型的权限系统的参考实现,使用filter和aop的方式,支持功能级控制和细粒度的数据过滤。

== 数据模型 ==

                       includes                 includes
                        .--.                     .---.
                        |  v                     |   v
  .------.    [URs]   .------.     [RPs]     .------------.    [PRs]   .----------.
  | User |<---------->| Role |<------T------>| Permission |<---------->| Resource |
  '------' *        * '------' *     |*    * '------------' 1        * '----------'
                                     |              | *
                                     |              | [PKs]
                                     |*             | *
                              .----------.       .-------.       .------.
                              |LimitGroup|<----->| Klass |<----->| Meta |
                              '----------'*     1'-------'1     *'------'
                                   1|                               |1
                                    |         .------------.        |
                                    '---------| limitScope |--------'
                                            * '------------'*

== 功能和特点 ==
* 功能授权使用 RBAC 模型
    支持RBAC LEVEL3
    授权策略包括 允许 拒绝 弃权(继承)
* 支持细粒度的数据级权限,通过元数据自定义条件设置访问数据的范围,支持数据的查询和更新,支持通过关联关系进行定义
    如支持定义业务员只能查看自己的订单,经理可以查看本部门订单等
    支持定义业务员只能填写5000以下金额的订单等
* 支持细粒度的访问权限,如ip,时间,params 等等...,可通过元数据自定义多种条件
    如支持定义仅某些网段可以使用某功能等
    支持定义仅某时间段可以使用某功能
* 支持 current_user.can_edit_topic? current_user.can_edit_topic_with(@topic) 等调用方法(method_missing),可以方便的根据授权控制界面
    如<%=link_to orders_path if current_user.can_index_orders%>
* 使用filter和AOP的方式实现权限控制和数据过滤,无须修改已有系统代码
    仅需要在系统中增加几行代码
    可自动生成系统元数据
* 使用数据库保存权限数据
    可在运行时修改权限定义
    使用缓存优化权限查询

* 绑定permission权限的菜单的实现
    根据当前用户权限,动态显示用户菜单
* 基于元数据的自定义查询
    controller:dynamic_searchable :index
    view:<%=dynamic_search_for Model%>
    即可实现基于元数据的动态查询
* 更详细的说明请参考 doc/doc.mm (FreeMind: http://freemind.sourceforge.net/wiki/index.php/Download)

! 本项目功能目前仅为参考实现,在生产环境使用请自行评估

== todo list ==
* 属性级权限,自定义对model每个属性的可见,可编辑权限
* 作为子项目、plugin或gem的形式发布
* 补充文档
* model 访问 context 的处理需要重构
* more and more

== 环境、gems 和 plugins ==
ruby: 1.8.7
rails: 2.3.3
测试:shoulda factory_girl shoulda_generator
分页:will_paginate
i18n: i18n_generator
nested_set: awesome_nested_set
缓存: memcached
其他:yaml_db

== 安装和运行 ==
安装依赖的 gems
配置 config/database.yml
rake db:create:all
rake db:migrate
rake db:data:load

默认管理员登录为 admin/admin


== rake stats ==
+----------------------+-------+-------+---------+---------+-----+-------+
| Name                 | Lines |   LOC | Classes | Methods | M/C | LOC/M |
+----------------------+-------+-------+---------+---------+-----+-------+
| Controllers          |   820 |   695 |      12 |      74 |   6 |     7 |
| Helpers              |    60 |    55 |       0 |       5 |   0 |     9 |
| Models               |   872 |   536 |      16 |      61 |   3 |     6 |
| Libraries            |   319 |   270 |       2 |      42 |  21 |     4 |
| Functional tests     |   197 |   149 |      11 |       8 |   0 |    16 |
| Unit tests           |   486 |   420 |      16 |       7 |   0 |    58 |
+----------------------+-------+-------+---------+---------+-----+-------+
| Total                |  2754 |  2125 |      57 |     197 |   3 |     8 |
+----------------------+-------+-------+---------+---------+-----+-------+
  Code LOC: 1556     Test LOC: 569     Code to Test Ratio: 1:0.4


by caryl
http://www.fandouai.com/articles/about_caryl
group: http://groups.google.com/group/rbace

About

It's a RBAC(Role Based Access Control) example based meta-data

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published