首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >zf2 bjyauthorize不加载登录角色

zf2 bjyauthorize不加载登录角色
EN

Stack Overflow用户
提问于 2016-02-11 05:21:55
回答 1查看 105关注 0票数 0

我已经安装了bjyauthorize,我从数据库中为角色、规则等设置了提供者,一切都加载得很好,除了即使我已经登录,当我调用$serviceManager->get('BjyAuthorize\Service\Authorize')->getIdentity();时,bjyauthorize只返回bjyauthorize-identity

我必须指出,如果我调用zf2身份服务,用户数据会被加载。

请告诉我在这里要写什么代码来帮助我得到答案。

代码语言:javascript
复制
<?php

return array(
    'bjyauthorize' => array(
        // default role for unauthenticated users
        'default_role' => 'guest',
        // default role for authenticated users (if using the
        // 'BjyAuthorize\Provider\Identity\AuthenticationIdentityProvider' identity provider)
        'authenticated_role' => 'user',
        // identity provider service name
        'identity_provider' => 'BjyAuthorize\Provider\Identity\AuthenticationIdentityProvider',
        // Role providers to be used to load all available roles into Zend\Permissions\Acl\Acl
        // Keys are the provider service names, values are the options to be passed to the provider
        'role_providers' => array(
            'Users\Authorize\Provider\Role\ObjectRepositoryProvider' => [
                    'object_manager' => 'doctrine.entitymanager.orm_default',
                    'role_entity_class' => 'Users\Entity\Role',
            ]
        ),
        // Resource providers to be used to load all available resources into Zend\Permissions\Acl\Acl
        // Keys are the provider service names, values are the options to be passed to the provider
        'resource_providers' => array(
            'Users\Authorize\Provider\Resource\ObjectRepositoryProvider' => [
                'object_manager' => 'doctrine.entitymanager.orm_default',
                'resource_entity_class' => 'Users\Entity\Resource',
            ],
        ),
        // Rule providers to be used to load all available rules into Zend\Permissions\Acl\Acl
        // Keys are the provider service names, values are the options to be passed to the provider
        'rule_providers' => array(
            'Users\Authorize\Provider\Rule\ObjectRepositoryProvider' => array(
                'object_manager' => 'doctrine.entitymanager.orm_default',
                'rule_entity_class' => 'Users\Entity\Rule',
            ),
        ),
        // Guard listeners to be attached to the application event manager
        'guards' => array(),
        // strategy service name for the strategy listener to be used when permission-related errors are detected
        'unauthorized_strategy' => 'Users\View\RedirectionStrategy',
        // Template name for the unauthorized strategy
        'template' => 'error/403',
        // cache options have to be compatible with Zend\Cache\StorageFactory::factory
        'cache_options' => array(
            'adapter' => array(
                'name' => 'memory',
            ),
            'plugins' => array(
                'serializer',
            )
        ),
        // Key used by the cache for caching the acl
        'cache_key' => 'bjyauthorize_acl'
    ),
);
?>
EN

回答 1

Stack Overflow用户

发布于 2016-02-15 20:14:57

我找到了答案,我要求了错误的服务:

代码语言:javascript
复制
$authorize_ = $serviceManager->get('BjyAuthorize\Service\Authorize');

最好的一个是:

代码语言:javascript
复制
$authorize = $serviceManager->get('BjyAuthorize\Provider\Identity\ProviderInterface');

第二个可用于以用户角色登录的请求

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

https://stackoverflow.com/questions/35326168

复制
相关文章

相似问题

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