简体   繁体   English

Yii框架:基于角色的访问控制

[英]Yii framework : role based access control

I am implementing role based access control using yii framework for the application mentioned in the Agile web application development using yii framework book.I have implemented every thing up to page number 189. 我正在使用yii框架为yii框架书中提到的敏捷Web应用程序开发中提到的应用程序实现基于角色的访问控制。我已经实现了第189页的所有内容。

page number 189 says that following method can be used to check whether user is allowed to perform some action or not. 页码189表示可以使用以下方法来检查是否允许用户执行某些操作。

If( Yii::app()->user->checkAccess('createIssue')) { //perform needed logic } If(Yii :: app()-> user-> checkAccess('createIssue')){//执行所需的逻辑}

but this method always return false for users who have been assigned to createIssue operation 但是对于分配给createIssue操作的用户,此方法始终返回false

following is the database diagram for RBAC 以下是RBAC的数据库图

在此处输入图片说明

i am linking UserID and role for authassignment table using following command. 我正在使用以下命令将用户ID和角色分配给authassignment表。

$auth=Yii::app()->authManager; $ auth = Yii :: app()-> authManager; $auth->assign('member',1); $ auth-> assign('member',1);

As you can see my user table and authassignment table does not have direct relationship. 如您所见,我的用户表和authassignment表没有直接关系。

And i have configured main.php file in configuration folder 而且我已经在配置文件夹中配置了main.php文件

These are the all we have done so far and could any body share your knowledge with me if any thing is missing here. 这些是我们到目前为止所做的一切,如果这里缺少任何内容,任何人都可以与我分享您的知识。 Thanks in advance for any help. 在此先感谢您的帮助。

Come on, man! 来吧,伙计! Of course there must be a direct relationship between users and assigments. 当然,用户和组织之间必须有直接的关系。 In the following piece of code: 在下面的代码中:

$auth=Yii::app()->authManager; $auth->assign('member',1)

'member' belongs to authiments, and '1' is the id of the user being assigned with that role. “成员”属于认证,“ 1”是被分配了该角色的用户的ID。 "userid", in the "authassigment" table, must point to users table. “身份验证”表中的“用户ID”必须指向用户表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM