2011-11-01 2 views
1

CakePHP 1.3에서 ACL을 단 한번도 사용하지 않고 2 주간의 격렬한 좌절로 CakePHP 2.0에서 여전히 작동하지 않습니다.CakePHP 2.0 : ACL이 작동하지 않습니다.

나는 Cake ACL 튜토리얼을 정확히 따라 왔지만 아무 일도 일어나지 않았다. 모든 Aros는 ACOS와 권한이 동일합니다.

이 모든 것 때문에 문제없이 모든 거부 된 작업을 입력 할 수 있습니다.

이로써 내 AppController가 내으로, beforeFilter에서

public $components = array('Acl','Auth'=> array(
          'authenticate' => array(
           'Actions', 
           'Form' => array(
            'fields' => array('username' => 'email') 
            ), 
          ) 
), 'Session', 'MathCaptcha', 'RequestHandler'); 

:

$this->Auth->actionPath = 'controllers'; 
    $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login'); 
    $this->Auth->logoutRedirect = array('controller' => 'pages', 'action' => 'home'); 
    $this->Auth->loginRedirect = array('controller' => 'users', 'action' => 'profile'); 
    $this->Auth->allow('display'); 

은 누군가가 잘못되면 어떤 생각을 가지고있다. 감사!

답변

2

이 aproach와

응용 프로그램/컨트롤러/AppController.php

class AppController extends Controller { 

    public $components = array(
     // others components... 
     'Session', 
     'Acl', 
     'Auth'=> array(
      // Setting AUTHORIZATION "What can you do?" 
      'authorize' => array(
       'Actions' => array(
        'actionPath' => 'controllers' 
       ) 
      ), 

      // Setting AUTHENTICATION "Who are you?" 
      'authenticate' => array(
       'Form' => array(
        'fields' => array(
         'username' => 'email', 'password' => 'password' 
        ) 
       ) 
      ) 
     ) 
    ); 

// other stuffs... 

은 ACL은 모든 더러운 일을 할 것입니다. 아마 알고있는 것처럼 permitions을 검사 할 필요가 없습니다.

나는 당신이 ARO와 ACO에 관해 좋아한다고 생각한다.별로 중요하지 않다. 바로 그 경우 : http://book.cakephp.org/2.0/en/tutorials-and-examples/simple-acl-controlled-application/simple-acl-controlled-application.html#simple-acl-controlled-application

CakeBook 2.0은 ACO를 빌드하는 AclExtras라는 콘솔 플러그인을 보여줍니다. ARO는 사용자 및 그룹이 추가/삭제 될 때 작성됩니다. 이미 채워진 테이블에 대해 ARO를 생성하기 위해이 플러그인을 사용했습니다 : http://www.alaxos.ch/blaxos/pages/view/plugin_acl. 이것은 fos 1.3에서 작동하지만 2.0 용 베타 버전은 정상적으로 작동합니다.

그런 다음 변환을 설정해야합니다. 이 링크가 설명하는대로 수동으로 (또는 콘솔에서) : http://book.cakephp.org/2.0/en/tutorials-and-examples/simple-acl-controlled-application/part-two.html#setting-up-permissions. 또는 Alaxos의 플러그인으로 시각적으로.

이 도움이 되었기를 바랍니다. 그것은 나를 위해 일했습니다. 나는 CakePHP 2.0.2를 사용하고있다.

+0

답변에 대한 많은 감사 Colares는 Scott의 답변과 함께 작동하도록했습니다. – ChrisDK

2

인증 구성 요소가 CakePHP 1.3에서 2.0으로 상당히 변경되었습니다. 1.3에서 2.0으로 앱을 이전하는 비슷한 문제에 부딪 혔습니다.

으로, beforeFilter에서 :

$this->Auth->authorize = array(
    'Actions' => array(
     'userModel' => 'User', 
     'actionPath' => 'users' 
    ) 
); 

userModel가 아로 테이블에 사용 된 모델 클래스이었다 난 내 변화를 만드는 데 필요한 경우 권한 부여 옵션을 설정하는 것을 발견했다. actionPath는 Aco 테이블에서 Acl이 확인하는 작업의 루트 수준입니다.

또한 허용 후 거부 할 수 있습니다 :이 도움이

$this->Auth->deny('*'); 
$this->Auth->allow('display'); 

희망을. 나는 이런 식으로했습니다 CakePHP는 2.0

+0

환상적이고, 많은 감사! – ChrisDK

관련 문제