ZF2 BJY授权不加载登录角色



我已经安装了bjyauthorize,我从数据库中设置了提供程序,用于角色,规则等,一切都加载正常,除了即使我登录,bjyauthorization在我调用时也只返回bjyauthorize-identity $serviceManager->get('BjyAuthorizeServiceAuthorize')->getIdentity();

我必须提到我是否调用 zf2 身份服务用户数据加载。

请告诉我在这里写哪段代码来帮助你得到答案。

<?php
return array(
    'bjyauthorize' => array(
        // default role for unauthenticated users
        'default_role' => 'guest',
        // default role for authenticated users (if using the
        // 'BjyAuthorizeProviderIdentityAuthenticationIdentityProvider' identity provider)
        'authenticated_role' => 'user',
        // identity provider service name
        'identity_provider' => 'BjyAuthorizeProviderIdentityAuthenticationIdentityProvider',
        // Role providers to be used to load all available roles into ZendPermissionsAclAcl
        // Keys are the provider service names, values are the options to be passed to the provider
        'role_providers' => array(
            'UsersAuthorizeProviderRoleObjectRepositoryProvider' => [
                    'object_manager' => 'doctrine.entitymanager.orm_default',
                    'role_entity_class' => 'UsersEntityRole',
            ]
        ),
        // Resource providers to be used to load all available resources into ZendPermissionsAclAcl
        // Keys are the provider service names, values are the options to be passed to the provider
        'resource_providers' => array(
            'UsersAuthorizeProviderResourceObjectRepositoryProvider' => [
                'object_manager' => 'doctrine.entitymanager.orm_default',
                'resource_entity_class' => 'UsersEntityResource',
            ],
        ),
        // Rule providers to be used to load all available rules into ZendPermissionsAclAcl
        // Keys are the provider service names, values are the options to be passed to the provider
        'rule_providers' => array(
            'UsersAuthorizeProviderRuleObjectRepositoryProvider' => array(
                'object_manager' => 'doctrine.entitymanager.orm_default',
                'rule_entity_class' => 'UsersEntityRule',
            ),
        ),
        // 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' => 'UsersViewRedirectionStrategy',
        // Template name for the unauthorized strategy
        'template' => 'error/403',
        // cache options have to be compatible with ZendCacheStorageFactory::factory
        'cache_options' => array(
            'adapter' => array(
                'name' => 'memory',
            ),
            'plugins' => array(
                'serializer',
            )
        ),
        // Key used by the cache for caching the acl
        'cache_key' => 'bjyauthorize_acl'
    ),
);
?>

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

$authorize_ = $serviceManager->get('BjyAuthorizeServiceAuthorize');

好的是:

$authorize = $serviceManager->get('BjyAuthorizeProviderIdentityProviderInterface');

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

最新更新