rbac权限那个一张表方法 小项目适用

浏览:872 发布日期:2013/02/03 分类:技术分享
觉得使用一张权限表就ok了 里面设三个字段
node 节点
level 等级 1为项目 2为模块 3为方法
gid 用户组

用户表中加个gid字段

用户登录的同时使用gid获取全部权限

将权限分组存到session

数据结构使用level作为key
就形成了这样的数据结构
array(
1=>array(); //项目
2=>array(); //模块
3=>array(); //方法
)

到 common类中
//先判断项目是否通过 在判断模块 最后判断方法
if (!in_array(strtolower(APP_NAME), $_SESSION['app'])) {
$this->error('无权访问项目!', __APP__ . '/Public/login');

}
if (!in_array(strtolower(MODULE_NAME), $_SESSION['module'])) {
$this->error('无权访问该模块!');

}
if (!in_array(strtolower(ACTION_NAME), $_SESSION['action'])) {
$this->error('无权访问该操作!');

}



最佳答案
评论( 相关
后面还有条评论,点击查看>>