Advertisement
Guest User

Untitled

a guest
Aug 26th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.97 KB | None | 0 0
  1. <?php
  2. /**
  3.  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  4.  * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  5.  *
  6.  * Licensed under The MIT License
  7.  * For full copyright and license information, please see the LICENSE.txt
  8.  * Redistributions of files must retain the above copyright notice.
  9.  *
  10.  * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  11.  * @link      http://cakephp.org CakePHP(tm) Project
  12.  * @since     0.2.9
  13.  * @license   http://www.opensource.org/licenses/mit-license.php MIT License
  14.  */
  15. namespace App\Controller;
  16.  
  17. use Cake\Controller\Controller;
  18. use Cake\Event\Event;
  19. use Cake\Core\Configure;
  20. use Ldap\Auth\LdapAuthenticate;
  21.  
  22. class AppController extends Controller
  23. {
  24.  
  25.     public function initialize()
  26.     {
  27.         parent::initialize();
  28.  
  29.         $this->loadComponent('RequestHandler');
  30.         $this->loadComponent('Flash');
  31.         $this->loadComponent('Auth', [
  32.             'authenticate' => [
  33.                 'Ldap.Ldap' => [
  34.                     'fields' => [
  35.                         'username' => 'username',
  36.                         'password' => 'password'
  37.                     ],
  38.                     'port' => Configure::read('Ldap.port'),
  39.                     'host' => Configure::read('Ldap.host'),
  40.                     'domain' => Configure::read('Ldap.domain'),
  41.                     'baseDN' => Configure::read('Ldap.baseDN'),
  42.                     'bindDN' => Configure::read('Ldap.bindDN'),
  43.                     'search' => Configure::read('Ldap.search'),
  44.                     'errors' => Configure::read('Ldap.errors'),
  45.                     'flash' => [
  46.                         'key' => 'ldap',
  47.                         'element' => 'Flash/error',
  48.                     ]
  49.                 ]
  50.             ],
  51.             'loginAction' => [
  52.                 'controller' => 'users',
  53.                 'action' => 'login'
  54.             ],
  55.             // 'unauthorizedRedirect' => [
  56.             //     'controller' => 'pages',
  57.             //     'action' => 'home',
  58.             //     'prefix' => false
  59.             // ],
  60.             'unauthorizedRedirect' => false,
  61.             'loginRedirect' => [
  62.                 'controller' => 'pages',
  63.                 'action' => 'admin',
  64.                 'prefix' => false
  65.             ],
  66.             'logoutRedirect' => [
  67.                 'controller' => 'pages',
  68.                 'action' => 'home',
  69.                 'prefix' => false
  70.             ],
  71.             'authError' => 'Sie besitzen nicht die nötigen Rechte um die angeforderte Seite zu sehen, bitte melden Sie sich an!',
  72.         ]);
  73.     }
  74.  
  75.     public function beforeFilter(Event $event)
  76.     {
  77.  
  78.     }
  79.  
  80.     public function beforeRender(Event $event)
  81.     {
  82.         if (!array_key_exists('_serialize', $this->viewVars) &&
  83.             in_array($this->response->type(), ['application/json', 'application/xml'])
  84.         ) {
  85.             $this->set('_serialize', true);
  86.         }
  87.     }
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement