首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在向bjyauthorize添加守卫时接收白色屏幕

在向bjyauthorize添加守卫时接收白色屏幕
EN

Stack Overflow用户
提问于 2014-09-15 06:12:43
回答 1查看 251关注 0票数 2

我是ZF2和bjyauthorize的新手,所以在某种程度上希望这是我的一个愚蠢的错误:D

我已经成功地安装了ZF2框架应用程序和zfcUser,并试图将bjyAuthorize添加到混合应用程序中。我还使用到mySQL的Zend/Db连接类型--而不是理论(:D)。我使用的版本是PHP5.5、ZF2(2.3.*)、zfcUser(1.2.1)、bjyAuthorize(1.4.0)。

我遵循了GitHub自述中找到的信件中的说明。没过多久,我就意识到这里的示例"bjyauthorize.global.php“文件包含了太多的设置(作为示例),并且在"\BjyAuthorize\Provider\Role\ZendDb::class”("role_id“/b "roleid")下也有一个不正确的字段引用。

基本上,只要我在配置文件中取消基于路由的或基于控制器的保护(我不打算两者都做--只想一个工作),我就会在试图访问我的主干应用程序主页时得到一个白屏幕--没有错误信息可以帮助。因此,我担心这是PHP语法错误。

我还包括了ZendDeveloperTools,甚至当我收到这个错误时,页脚上的工具栏也不会出现。

下面是我的配置文件:

代码语言:javascript
复制
<?php

return [
    'bjyauthorize' => [

        // set the 'guest' role as default (must be defined in a role provider)
        'default_role' => 'guest',

        /* this module uses a meta-role that inherits from any roles that should
         * be applied to the active user. the identity provider tells us which
         * roles the "identity role" should inherit from.
         *
         * for ZfcUser, this will be your default identity provider
         */
        'identity_provider' => \BjyAuthorize\Provider\Identity\ZfcUserZendDb::class,

        /* role providers simply provide a list of roles that should be inserted
         * into the Zend\Acl instance. the module comes with two providers, one
         * to specify roles in a config file and one to load roles using a
         * Zend\Db adapter.
         */
        'role_providers' => [
            // this will load roles from the user_role table in a database
            // format: user_role(role_id(varchar], parent(varchar))
            \BjyAuthorize\Provider\Role\ZendDb::class => [
                'table'                 => 'user_role',
                'identifier_field_name' => 'id',
                'role_id_field'         => 'roleid',
                'parent_role_field'     => 'parent_id',
            ],
        ],

        /* Currently, only controller and route guards exist
         *
         * Consider enabling either the controller or the route guard depending on your needs.
         */
        'guards' => [
            /* If this guard is specified here (i.e. it is enabled], it will block
             * access to all controllers and actions unless they are specified here.
             * You may omit the 'action' index to allow access to the entire controller
             */
//             \BjyAuthorize\Guard\Controller::class => [
//                 ['controller' => 'zfcuser', 'roles' => ['guest']],
//                 ['controller' => ['Application\Controller\Index'], 'roles' => ['guest']],
//             ],

//             /* If this guard is specified here (i.e. it is enabled], it will block
//              * access to all routes unless they are specified here.
//              */
//             \BjyAuthorize\Guard\Route::class => [
//                 ['route' => 'zfcuser', 'roles' => ['user']],
//                 ['route' => 'zfcuser/logout', 'roles' => ['user']],
//                 ['route' => 'zfcuser/login', 'roles' => ['guest']],
//                 ['route' => 'zfcuser/register', 'roles' => ['guest']],
//                 // Below is the default index action used by the ZendSkeletonApplication
//                 ['route' => 'home', 'roles' => ['guest', 'user']],
//             ],
         ],
    ],
];

当我在没有保护的情况下按上面的代码运行时,我可以通过site/ user /login登录,Zend向我展示了该用户的正确角色。所以这至少是积极的。

很高兴提供任何进一步的信息或设置-只是尝试学习。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-09-16 06:14:21

好吧,所以我现在觉得很傻。

bjyauthorize附带的DB模式包含"roleId“字段--在我上面的代码中,我没有考虑大小写敏感性,而是具有"roleid”。改变了这一切一切都完美无缺。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25841816

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档