首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >当应用程序从子目录运行时,BjyAuthorize拒绝访问

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

Stack Overflow用户
提问于 2013-05-16 09:10:29
回答 1查看 957关注 0票数 0

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

知道吗?

编辑这里是我的配置。

代码语言:javascript
复制
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'
        )
    )
)

);

EN

回答 1

Stack Overflow用户

发布于 2013-05-16 09:43:41

您在RewriteBase文件中将目录添加到.htaccess中了吗?我只在子目录下运行我的应用程序,BjyAuthorize没有问题。

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

https://stackoverflow.com/questions/16583336

复制
相关文章

相似问题

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