2013-05-16 35 views
0

我遇到BjyAuthorize問題。當應用程序位於虛擬主機的根文件夾中時,我可以訪問在guard參數中定義的路徑,但是當應用程序從子目錄運行時,我從BjyAuthorize中獲取了拒絕訪問(錯誤403),儘管我已指定在view_manager base_path的參數中的子目錄。BjyAuthorize拒絕從子目錄運行應用程序時的訪問

有什麼想法?

編輯 這是我的配置。

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' 
     ) 
    ) 
) 

);

回答

0

您是否在.htaccess文件中將您的目錄添加到了RewriteBase?我只在一個子目錄中運行我的應用程序,並且沒有BjyAuthorize問題。

+0

是的子目錄也被設置爲.htaccess中的RewriteBase –

+0

請向我們展示您的配置。我認爲有一個錯誤。 – KFO