duanduji2986 2012-10-23 05:26
浏览 3
已采纳

如何在Zend Framework 2中设置BjyAuthorize?

I'm trying to use BjyAuthorize in a sample application in ZF2 and I have a bit of an issue setting it up.

I have an Admin module and I want to give permissions for the user to access it. I also have the ZfcUser module and that one seems to work just fine with this acl.

The way I set up the db's is like his:

user_role
role_id     default     parent
------------------------------
user        1           admin
admin       2           NULL


user_role_linker
user_id     role_id
-------------------
1           user

I'm not sure this is set up correctly, also I'm not sure why role_id is a varchar ??!!

In any case, with this setup the ZfcUser works just fine.

The problem is when I try to use a different module, where I add:

array('controller' => 'Admin\Controller\Index', 'roles' => array('guest','user'))

I get

403 Forbidden You are not authorized to access Admin\Controller\Admin ::indexAction() .

In the README file it is mentioned that I could use $this->isAllowed($resource[, $privilege]) in my controller or view, but that code is wrong and I'm not sure what is the $resource or the $privilege

So I guess my question is how can I use this module? Did anyone got it to work?

  • 写回答

2条回答 默认 最新

  • doujian1050 2012-10-26 23:13
    关注

    i found a solution that lets me work with ZfcUser and BjyAuthorize called ZfcUser-BjyAuthorize-Bridge

    Also managed to make the modules work with the roles just by fallowing the BjyAuthorisation documentation again and again and again.

    I set up a testing environment on github here that prettily much works as a starting point with all those modules.

    note: this module will change as it's more of a playground for me

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探