简体   繁体   English

如何通过 DbManager 获取 Yii2 RBAC 使用 Joomla“用户”表和 Joomla 会话中的用户 ID?

[英]How do I get Yii2 RBAC via DbManager use Joomla "user" table and userid from Joomla session?

I have Joomla running to control the placement of content and to manage user registration/login.我运行 Joomla 来控制内容的放置并管理用户注册/登录。 Also I have Yii2 running which I integrated by following these instructions: http://www.yiiframework.com/doc-2.0/guide-tutorial-yii-integration.html我还运行了 Yii2,我按照以下说明进行了集成: http ://www.yiiframework.com/doc-2.0/guide-tutorial-yii-integration.html

I want a user to be able to login through Joomla's login system, and then use Yii2's built-in RBAC support via DbManager ( http://www.yiiframework.com/doc-2.0/guide-security-authorization.html#rbac ) to verify the logged in user's permissions in the auth_assignment table before running a particular Yii2 function.我希望用户能够通过 Joomla 的登录系统登录,然后通过 DbManager ( http://www.yiiframework.com/doc-2.0/guide-security-authorization.html#rbac ) 使用 Yii2 的内置 RBAC 支持在运行特定的 Yii2 函数之前,在 auth_assignment 表中验证登录用户的权限。

I'm not sure what I have to do to tell Yii2 to use the "user" table used by Joomla and also to check this table for the userid when performing RBAC permission checks such as the following example:我不确定我必须做什么才能告诉 Yii2 使用 Joomla 使用的“用户”表,并在执行 RBAC 权限检查时检查该表的用户 ID,例如以下示例:

if (Yii::$app->user->can('some-auth-item')) 
    { 
        return $this->render('some-page'); 
    }

I think this link could be usefule http://www.yiiframework.com/forum/index.php/topic/67481-integrating-yii2-into-joomla-and-using-joomlas-user-table/我认为这个链接可能有用http://www.yiiframework.com/forum/index.php/topic/67481-integrating-yii2-into-joomla-and-using-joomlas-user-table/

Mainly You need change the user table主要是您需要更改用户表

class User extends ActiveRecord implements IdentityInterface
{

  public static function tableName()
  {
     return 'fm3lk_user';
  }

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

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