当应用程序从子目录运行时,BjyAuthorize拒绝访问

时间:2013-05-16 09:10:30

标签: zend-framework zend-framework2 zend-route bjyauthorize

我遇到了BjyAuthorize的问题。当应用程序位于我的虚拟主机的根文件夹中时,我可以毫无问题地访问guards参数中定义的路由,但是当应用程序从子目录运行时,我从BjyAuthorize获得访问被拒绝(错误403),尽管我被指定了view_manager base_path参数中的子目录。

有什么想法吗?

修改 这是我的配置。

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\ZfcUserZendDb',

    // 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(
        /* here, 'guest' and 'user are defined as top-level roles, with
         * 'admin' inheriting from user
        */
        'BjyAuthorize\Provider\Role\Config' => array(
            'guest' => array(),
            'user' => array(
                'children' => array(
                    'admin' => array()
                )
            )
        ),

        // this will load roles from the user_role table in a database
        // format: user_role(role_id(varchar), parent(varchar))
        'BjyAuthorize\Provider\Role\ZendDb' => array(
            'table' => 'user_role',
            'role_id_field' => 'role_id',
            'parent_role_field' => 'parent'
        )
    ),

    // 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(),

    // 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(),

    // Guard listeners to be attached to the application event manager
    'guards' => array(  
        /* 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' => array(
            array(
                'route' => 'zfcuser',
                'roles' => array(
                    'user'
                )
            ),
            array(
                'route' => 'zfcuser/logout',
                'roles' => array(
                    'user'
                )
            ),
            array(
                'route' => 'zfcuser/login',
                'roles' => array(
                    'guest'
                )
            ),
            array(
                'route' => 'zfcuser/register',
                'roles' => array(
                    'admin'
                )
            ),
            // Below is the default index action used by the ZendSkeletonApplication
            array(
                'route' => 'home',
                'roles' => array(
                    'guest',
                    'user'
                )
            )
        )
    ),

    // strategy service name for the strategy listener to be used when permission-related errors are detected
    'unauthorized_strategy' => 'BjyAuthorize\View\UnauthorizedStrategy',

    // Template name for the unauthorized strategy
    'template' => 'error/403'
),

'service_manager' => array(
    'factories' => array(
        'BjyAuthorize\Config' => 'BjyAuthorize\Service\ConfigServiceFactory',
        'BjyAuthorize\Guards' => 'BjyAuthorize\Service\GuardsServiceFactory',
        'BjyAuthorize\RoleProviders' => 'BjyAuthorize\Service\RoleProvidersServiceFactory',
        'BjyAuthorize\ResourceProviders' => 'BjyAuthorize\Service\ResourceProvidersServiceFactory',
        'BjyAuthorize\RuleProviders' => 'BjyAuthorize\Service\RuleProvidersServiceFactory',
        'BjyAuthorize\Guard\Controller' => 'BjyAuthorize\Service\ControllerGuardServiceFactory',
        'BjyAuthorize\Guard\Route' => 'BjyAuthorize\Service\RouteGuardServiceFactory',
        'BjyAuthorize\Provider\Role\Config' => 'BjyAuthorize\Service\ConfigRoleProviderServiceFactory',
        'BjyAuthorize\Provider\Role\ZendDb' => 'BjyAuthorize\Service\ZendDbRoleProviderServiceFactory',
        'BjyAuthorize\Provider\Resource\Config' => 'BjyAuthorize\Service\ConfigResourceProviderServiceFactory',
        'BjyAuthorize\Service\Authorize' => 'BjyAuthorize\Service\AuthorizeFactory',
        'BjyAuthorize\Provider\Identity\ProviderInterface' => 'BjyAuthorize\Service\IdentityProviderServiceFactory',
        'BjyAuthorize\Provider\Identity\AuthenticationIdentityProvider' => 'BjyAuthorize\Service\AuthenticationIdentityProviderServiceFactory',
        'BjyAuthorize\Provider\Role\ObjectRepositoryProvider' => 'BjyAuthorize\Service\ObjectRepositoryRoleProviderFactory',
        'BjyAuthorize\Collector\RoleCollector' => 'BjyAuthorize\Service\RoleCollectorServiceFactory',
        'BjyAuthorize\Provider\Identity\ZfcUserZendDb' => 'BjyAuthorize\Service\ZfcUserZendDbIdentityProviderServiceFactory',
        'BjyAuthorize\View\UnauthorizedStrategy' => 'BjyAuthorize\Service\UnauthorizedStrategyServiceFactory'
    ),
    'invokables' => array(
        'BjyAuthorize\View\RedirectionStrategy' => 'BjyAuthorize\View\RedirectionStrategy'
    ),
    'aliases' => array(
        'bjyauthorize_zend_db_adapter' => 'Zend\Db\Adapter\Adapter'
    ),
    'initializers' => array(
        'BjyAuthorize\Service\AuthorizeAwareServiceInitializer' => 'BjyAuthorize\Service\AuthorizeAwareServiceInitializer'
    )
),

'view_manager' => array(
    'template_map' => array(
        'error/403' => realpath('./module/Application/view/error/403.phtml'),
        'zend-developer-tools/toolbar/bjy-authorize-role' => __DIR__ . '/../view/zend-developer-tools/toolbar/bjy-authorize-role.phtml'
    )
),

'zenddevelopertools' => array(
    'profiler' => array(
        'collectors' => array(
            'bjy_authorize_role_collector' => 'BjyAuthorize\Collector\RoleCollector'
        )
    ),
    'toolbar' => array(
        'entries' => array(
            'bjy_authorize_role_collector' => 'zend-developer-tools/toolbar/bjy-authorize-role'
        )
    )
)

);

1 个答案:

答案 0 :(得分:0)

您是否已将目录添加到.htaccess文件中的RewriteBase?我只在一个子目录中运行我的应用程序,与BjyAuthorize没有任何问题。