2014-08-29 8 views
0

내가 뭔가 잘못하고 있습니다. 모듈에 대한 액세스를 제한하고 싶습니다. 로그인 한 사용자 만 tijdmachine 모듈에 액세스 할 수 있습니다. ZF2, module.config의 ByjAuthorize 규칙

<?php 

namespace Tijdmachine; 

return array(
    'resource_providers' => array(
     'BjyAuthorizeProviderResourceConfig' => array(
      'tijdmachine' => array(), 
     ), 
    ), 
    'rule_providers' => array(
     'BjyAuthorizeProviderRuleConfig' => array(
      'allow' => array(
       array(array('user'), 'tijdmachine', array('index')), 
      ), 
     ), 
    ), 

     'view_manager' => array(
      'template_path_stack' => array(__DIR__ . '/../view') 
    ), 

    'controllers' => array(
     'invokables' => array(
      'Tijdmachine\Controller\IndexController' => 'Tijdmachine\Controller\IndexController', 
     ) 
    ), 


    'router' => array(
     'routes' => array(
     'tijdmachine' => array(
      'resource' => 'tijdmachine', 
      'privilege' => 'index', 
      'type' => 'segment', 
      'options' => array(
       'route' => '/tijdmachine', 
       // <---- url format module/action/id 
       'constraints' => array(
        'action' => '[a-zA-Z][a-zA-Z0-9_-]*', 
        'id'  => '[0-9]+', 
       ), 
       'defaults' => array(
        'controller' => 'Tijdmachine\Controller\IndexController', 
        // <--- Defined as the module controller 
        'action'  => 'index', 
        // <---- Default action 
       ), 
      ), 
     ), 
    ), 
    ), 

); 

내가 자원, 권한을 정의 내 경로에서 그들을 이름 :

이 내 module.config.php입니다. 그러나 특정 URL로 이동하면 로그인하지 않고도 모든 정보를 볼 수 있습니다. 내가 뭘 잘못하고 있니?

미리 감사드립니다.

+0

'자원'과 '특권'을 [탐색 용기 (HTTPS의 매개 변수입니다. org/ko/latest/modules/zend.navigation.pages.html # common-page-features)을 참조하십시오. – AlexP

답변

1

the documentation에 명시된 바와 같이, 당신은 설정에서 클래스 이름을 사용해야합니다 //zf2.readthedocs :

return array(
    'resource_providers' => array(
     'BjyAuthorize\Provider\Resource\Config' => array(
      'tijdmachine' => array(), 
     ), 
    ), 
    'rule_providers' => array(
     'BjyAuthorize\Provider\Rule\Config' => array(
      'allow' => array(
       array(array('user'), 'tijdmachine', array('index')), 
      ), 
     ), 
    ), 
    ... 
    '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::class => array(
      ['route' => 'tijdmachine', 'roles' => ['user']], 
     ), 
    ), 
); 
+0

글쎄, 나는 실제로 그 부분을 읽었다. 그것을 시험해 보았지만 행운은 없었습니다. 따라서, 나는 당신의 코드를 사용하려고 시도했다. – Chilion

+0

당신은'Role Provider'가 설정되어 있지 않고'default_role''도없고, 라우트 가드 설정이 없습니다. 나는 당신이 문서를 다시 읽고 제안 된 모든 단계를 수행 할 것을 제안한다. – NDM

+0

공급 업체/bjyauthorize/설정/module.config.php -> 반환 배열 ( 'bjyauthorize'=> 배열 (인증되지 않은 사용자 'default_role'=> '손님'에 대한 // 기본 역할, // 기본 역할에 대한 인증 된 사용자 ( // 'BjyAuthorize \ Provider \ Identity \ AuthenticationIdentityProvider'ID 제공 업체) 'authenticated_role'=> 'user', – Chilion