Exemplo n.º 1
0
 public function __construct(ComponentRegistry $registry, array $config = [])
 {
     parent::__construct($registry, $config);
     if ($this->user('role')) {
         $this->role = $this->user('role');
     }
     if (!file_exists(CONFIG . "locker.php")) {
         throw new Exception(_('locker.php not found in config directory'));
     }
     //Load configuration directives for Locker
     $params = $this->request->params;
     Configure::load('locker');
     $this->roles = Configure::read('locker.roles');
     $this->controllers = Configure::read('locker.controllers');
     $path = "/{$params['controller']}/{$params['action']}";
     if (!empty($params['prefix'])) {
         $path = "/{$params['prefix']}" . $path;
     }
     if (!empty($params['plugin'])) {
         $path = "/{$params['plugin']}" . $path;
     }
     $base = strtolower($path);
     $exact = strtolower($path . '/' . implode('/', $params['pass']));
     $wildcard = strtolower($base . '/*');
     if ($this->role != 'public' && !in_array($this->role, $this->roles)) {
         throw new Exception(__('Your user role is not present in locker configuration'));
     }
     if (!empty($this->controllers[$exact])) {
         if ($this->check($exact)) {
             return $this->allow();
         }
         if ($this->user()) {
             throw new MethodNotAllowedException(sprintf(__("You do not have permission to access this area: %s"), $exact));
         }
         return;
     }
     if (!empty($this->controllers[$wildcard]) && !empty($params['pass'])) {
         if ($this->check($wildcard)) {
             return $this->allow();
         }
         if ($this->user()) {
             throw new MethodNotAllowedException(sprintf(__("You do not have permission to access this area: %s"), $wildcard));
         }
         return;
     }
     if (!empty($this->controllers[$base])) {
         if ($this->check($base)) {
             return $this->allow();
         }
         if ($this->user()) {
             throw new MethodNotAllowedException(sprintf(__("You do not have permission to access this area: %s"), $base));
         }
         return;
     }
     throw new Exception(__('Method is not present on locker.php configuration'));
 }
Exemplo n.º 2
0
 public function __construct(ComponentRegistry $registry, array $config = [])
 {
     $this->components = array_merge($this->components, ['AclManager.Acl']);
     parent::__construct($registry, $config);
 }
Exemplo n.º 3
0
 /**
  * Constructor
  * @param ComponentRegistry $registry A ComponentRegistry this component
  *  can use to lazy load its components
  * @param array $config Array of configuration settings
  * @return void
  */
 public function __construct(ComponentRegistry $registry, array $config = [])
 {
     //Sets config
     $config = am(['authenticate' => ['Form' => ['contain' => 'Groups', 'userModel' => 'MeCms.Users']], 'authError' => __d('me_cms', 'You are not authorized for this action'), 'authorize' => 'Controller', 'flash' => ['element' => 'MeTools.error'], 'loginAction' => ['_name' => 'login'], 'loginRedirect' => ['_name' => 'dashboard'], 'logoutRedirect' => ['_name' => 'homepage'], 'unauthorizedRedirect' => ['_name' => 'dashboard']], $config);
     parent::__construct($registry, $config);
 }
 /**
  * @param \Cake\Controller\ComponentRegistry $registry
  * @param array $config
  * @throws \Cake\Core\Exception\Exception
  */
 public function __construct(ComponentRegistry $registry, array $config = [])
 {
     $config += $this->_defaultTinyAuthConfig;
     parent::__construct($registry, $config);
 }
 /**
  * Constructor
  *
  * @param ComponentRegistry $registry A ComponentRegistry this component can use to lazy load its components
  * @param array $config Array of configuration settings.
  */
 public function __construct(ComponentRegistry $registry, array $config = [])
 {
     $this->_defaultConfig = $this->_defaultConfig + $this->_defaultAdditionalConfig;
     parent::__construct($registry, $config);
 }