我已经安装了bjyauthorize,我从数据库中为角色、规则等设置了提供者,一切都加载得很好,除了即使我已经登录,当我调用$serviceManager->get('BjyAuthorize\Service\Authorize')->getIdentity();时,bjyauthorize只返回bjyauthorize-identity
我必须指出,如果我调用zf2身份服务,用户数据会被加载。
请告诉我在这里要写什么代码来帮助我得到答案。
<?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'
),
);
?>发布于 2016-02-15 20:14:57
我找到了答案,我要求了错误的服务:
$authorize_ = $serviceManager->get('BjyAuthorize\Service\Authorize');最好的一个是:
$authorize = $serviceManager->get('BjyAuthorize\Provider\Identity\ProviderInterface');第二个可用于以用户角色登录的请求
https://stackoverflow.com/questions/35326168
复制相似问题