/**
  * Constructor
  *
  * @param \Cake\Controller\ComponentRegistry $registry The Component registry
  *   used on this request.
  * @param array $config Array of config to use.
  */
 function __construct(ComponentRegistry $collection, $settings = array())
 {
     $this->form_fields = Configure::read('Ldap.form_fields');
     $this->form_fields = isset($settings['form_fields']) ? $settings['form_fields'] : $this->form_fields;
     $this->Yalp = new YalpUtility($settings);
     parent::__construct($collection, $settings);
 }
 /**
  * Constructor
  *
  * @param \Cake\Controller\ComponentRegistry $registry The Component registry used on this request.
  * @param array $config Array of config to use.
  */
 public function __construct(ComponentRegistry $registry, array $config = [])
 {
     parent::__construct($registry, $config);
     if (!defined('LDAP_OPT_DIAGNOSTIC_MESSAGE')) {
         define('LDAP_OPT_DIAGNOSTIC_MESSAGE', 0x32);
     }
     if (isset($config['host']) && is_object($config['host']) && $config['host'] instanceof \Closure) {
         $config['host'] = $config['host']();
     }
     if (empty($config['host'])) {
         throw new InternalErrorException('LDAP Server not specified!');
     }
     if (empty($config['port'])) {
         $config['port'] = null;
     }
     if (isset($config['logErrors']) && $config['logErrors'] === true) {
         $this->logErrors = true;
     }
     try {
         $this->ldapConnection = ldap_connect($config['host'], $config['port']);
         if (isset($config['options']) && is_array($config['options'])) {
             foreach ($config['options'] as $option => $value) {
                 ldap_set_option($this->ldapConnection, $option, $value);
             }
         } else {
             ldap_set_option($this->ldapConnection, LDAP_OPT_NETWORK_TIMEOUT, 5);
         }
     } catch (Exception $e) {
         throw new InternalErrorException('Unable to connect to specified LDAP Server(s)!');
     }
 }
Beispiel #3
0
 /**
  * Constructor
  *
  * @param \Cake\Controller\ComponentRegistry $registry The Component registry used on this request.
  * @param array $config Array of config to use.
  */
 public function __construct(ComponentRegistry $registry, array $config = [])
 {
     parent::__construct($registry, $config);
     $this->_controller = $registry->getController();
     if (!isset($this->_controller->Cookie)) {
         $this->_controller->loadComponent('Cookie');
     }
 }
Beispiel #4
0
 public function __construct(ComponentRegistry $registry, array $config = [], Auth0 $auth0 = null)
 {
     parent::__construct($registry, $config);
     if ($auth0 === null) {
         $this->_auth0 = new Auth0(['domain' => $this->_configRead('domain'), 'client_id' => $this->_configRead('client_id'), 'client_secret' => $this->_configRead('client_secret'), 'redirect_uri' => $this->_configRead('redirect_uri')]);
     } else {
         $this->_auth0 = $auth0;
     }
 }
Beispiel #5
0
 /**
  * Constructor
  *
  * @param \Cake\Controller\ComponentRegistry $registry The Component registry used on this request.
  * @param array $config Array of config to use.
  * @throws \Exception
  */
 public function __construct(ComponentRegistry $registry, array $config = [])
 {
     $oauthConfig = Configure::read('OAuth');
     //We unset twitter from providers to exclude from OAuth2 config
     unset($oauthConfig['providers']['twitter']);
     Configure::write('OAuth2', $oauthConfig);
     $config = $this->normalizeConfig(array_merge($config, $oauthConfig));
     parent::__construct($registry, $config);
 }
Beispiel #6
0
 public function __construct(ComponentRegistry $registry, array $config = [])
 {
     parent::__construct($registry, $config);
     if (Configure::read('CAS.debug_log_enabled')) {
         phpCAS::setDebug(TMP . 'phpCas.log.txt');
     }
     phpCAS::client(CAS_VERSION_2_0, Configure::read('CAS.hostname'), Configure::read('CAS.port'), Configure::read('CAS.uri'));
     $certServer = Configure::read('CAS.cert_path');
     if (empty($certServer)) {
         phpCAS::setNoCasServerValidation();
     } else {
         phpCAS::setCasServerCACert($certServer);
     }
 }
 /**
  * @param \Cake\Controller\ComponentRegistry $registry Component registry
  * @param array $config Config array
  */
 public function __construct(ComponentRegistry $registry, $config)
 {
     parent::__construct($registry, $config);
     if ($this->config('server')) {
         $this->Server = $this->config('server');
     } else {
         $sessionStorage = new Storage\SessionStorage();
         $accessTokenStorage = new Storage\AccessTokenStorage();
         $clientStorage = new Storage\ClientStorage();
         $scopeStorage = new Storage\ScopeStorage();
         $server = new ResourceServer($sessionStorage, $accessTokenStorage, $clientStorage, $scopeStorage);
         $this->Server = $server;
     }
 }
 /**
  * @param \Cake\Controller\ComponentRegistry $registry Component registry
  * @param array $config Config array
  */
 public function __construct(ComponentRegistry $registry, $config)
 {
     parent::__construct($registry, $config);
     if ($this->config('server')) {
         $this->Server = $this->config('server');
         return;
     }
     $serverConfig = $this->config('resourceServer');
     $serverClassName = App::className($serverConfig['className']);
     if (!$serverClassName) {
         throw new Exception('ResourceServer class was not found.');
     }
     $server = new $serverClassName($this->_getStorage('session'), $this->_getStorage('accessToken'), $this->_getStorage('client'), $this->_getStorage('scope'));
     $this->Server = $server;
 }
 /**
  * After succefully logged in a user, here we check if the remember me option was checked and set the cookie if so.
  *
  * @param Event $event Event object
  * @param array $result array of user data
  * @param BaseAuthenticate $auth Autheticate object that succesfully logged user in
  * @return void
  */
 public function afterIdentify(Event $event, array $result, BaseAuthenticate $auth)
 {
     /* @var Request $request */
     $request = $event->subject()->request;
     if (!$request->data($this->_config['cookieFields']['rememberMe'])) {
         return;
     }
     $_authConfig = $auth->config();
     $_username = $request->data($_authConfig['fields']['username']);
     $identifier = $this->_generateIdentifier($_username);
     $token = $this->_generateToken();
     $this->storage()->write($identifier, ['username' => $_username, 'token' => $token]);
     // seteamos la cookie
     $cookieFields = $this->_config['cookieFields'];
     $this->_setCookies([$cookieFields['identifier'] => $identifier, $cookieFields['token'] => $token]);
 }
Beispiel #10
0
 /**
  * Constructor
  *
  * @param \Cake\Controller\ComponentRegistry $registry The Component registry used on this request.
  * @param array $config Array of config to use.
  * @throws \Exception
  */
 public function __construct(ComponentRegistry $registry, array $config = [])
 {
     $oauthConfig = Configure::read('OAuth');
     //We unset twitter from providers to exclude from OAuth2 config
     unset($oauthConfig['providers']['twitter']);
     $providers = [];
     foreach ($oauthConfig['providers'] as $provider => $options) {
         if (!empty($options['options']['redirectUri']) && !empty($options['options']['clientId']) && !empty($options['options']['clientSecret'])) {
             $providers[$provider] = $options;
         }
     }
     $oauthConfig['providers'] = $providers;
     Configure::write('OAuth2', $oauthConfig);
     $config = $this->normalizeConfig(array_merge($config, $oauthConfig));
     parent::__construct($registry, $config);
 }
Beispiel #11
0
 /**
  * Constructor
  *
  * @param \Cake\Controller\ComponentRegistry $registry
  *        	The Component registry used on this request.
  * @param array $config
  *        	Array of config to use.
  */
 public function __construct(ComponentRegistry $registry, array $config = [])
 {
     parent::__construct($registry, $config);
     if (!defined('LDAP_OPT_DIAGNOSTIC_MESSAGE')) {
         define('LDAP_OPT_DIAGNOSTIC_MESSAGE', 0x32);
     }
     $this->_config['port'] = Configure::read('Ldap.port');
     $this->_config['host'] = Configure::read('Ldap.host');
     $this->_config['bindAccount'] = Configure::read('Ldap.bindAccount');
     $this->_config['bindPassword'] = Configure::read('Ldap.bindPassword');
     $this->_config['baseDN'] = Configure::read('Ldap.baseDN');
     $this->_config['filter'] = Configure::read('Ldap.filter');
     $this->_config['return'] = Configure::read('Ldap.return');
     $this->_config['errors'] = Configure::read('Ldap.errors');
     if (empty($this->_config['host'])) {
         throw new InternalErrorException('LDAP Server not specified!');
     }
     if (empty($this->_config['port'])) {
         $this->_config['port'] = null;
     }
     $this->connect();
 }
Beispiel #12
0
 /**
  * {@inheritDoc}
  */
 public function __construct(ComponentRegistry $registry, array $config = [])
 {
     //Configuration params can be set via global Configure::write or via Auth->config
     //Auth->config params override global Configure, so we'll pass them in last
     parent::__construct($registry, (array) Configure::read('CAS'));
     $this->config($config);
     //Get the merged config settings
     $settings = $this->config();
     if (!empty($settings['debug'])) {
         phpCAS::setDebug(LOGS . 'phpCas.log');
     }
     phpCAS::client(CAS_VERSION_2_0, $settings['hostname'], $settings['port'], $settings['uri']);
     if (empty($settings['cert_path'])) {
         phpCAS::setNoCasServerValidation();
     } else {
         phpCAS::setCasServerCACert($settings['cert_path']);
     }
     if (!empty($registry)) {
         $controller = $registry->getController();
         if (!empty($controller)) {
             $this->eventManager($controller->eventManager());
         }
     }
 }
 /**
  * Constructor.
  *
  * Settings for this object.
  *
  * - `parameter` - The url parameter name of the token. Defaults to `_token`.
  *   First $_SERVER['HTTP_AUTHORIZATION'] is checked for token value.
  *   Its value should be of form "Bearer <token>". If empty this query string
  *   paramater is checked.
  * - `userModel` - The model name of the User, defaults to `Users`.
  * - `fields` - Has key `id` whose value contains primary key field name.
  *   Defaults to ['id' => 'id'].
  * - `scope` - Additional conditions to use when looking up and authenticating
  *   users, i.e. `['Users.is_active' => 1].`
  * - `contain` - Extra models to contain.
  * - `unauthenticatedException` - Fully namespaced exception name. Exception to
  *   throw if authentication fails. Set to false to do nothing.
  *   Defaults to '\Cake\Network\Exception\UnauthorizedException'.
  * - `allowedAlgs` - List of supported verification algorithms.
  *   Defaults to ['HS256']. See API of JWT::decode() for more info.
  *
  * @param \Cake\Controller\ComponentRegistry $registry The Component registry
  *   used on this request.
  * @param array $config Array of config to use.
  */
 public function __construct(ComponentRegistry $registry, $config)
 {
     $this->config(['parameter' => '_token', 'fields' => ['id' => 'id'], 'unauthenticatedException' => '\\Cake\\Network\\Exception\\UnauthorizedException', 'allowedAlgs' => ['HS256']]);
     parent::__construct($registry, $config);
 }
 /**
  * Constructor
  *
  * @param ComponentRegistry $registry The Component registry used on this request.
  * @param array $config Array of config to use.
  */
 public function __construct(ComponentRegistry $registry, array $config = [])
 {
     $this->_defaultConfig['fields']['secret'] = 'secret';
     parent::__construct($registry, $config);
 }
 /**
  * Constructor.
  *
  * Settings for this object.
  *
  * - `header` - Header name to check. Defaults to `'authorization'`.
  * - `prefix` - Token prefix. Defaults to `'bearer'`.
  * - `parameter` - The url parameter name of the token. Defaults to `token`.
  *   First $_SERVER['HTTP_AUTHORIZATION'] is checked for token value.
  *   Its value should be of form "Bearer <token>". If empty this query string
  *   paramater is checked.
  * - `allowedAlgs` - List of supported verification algorithms.
  *   Defaults to ['HS256']. See API of JWT::decode() for more info.
  * - `queryDatasource` - Boolean indicating whether the `sub` claim of JWT
  *   token should be used to query the user model and get user record. If
  *   set to `false` JWT's payload is directly retured. Defaults to `true`.
  * - `userModel` - The model name of users, defaults to `Users`.
  * - `fields` - Key `username` denotes the identifier field for fetching user
  *   record. The `sub` claim of JWT must contain identifier value.
  *   Defaults to ['username' => 'id'].
  * - `finder` - Finder method.
  * - `unauthenticatedException` - Fully namespaced exception name. Exception to
  *   throw if authentication fails. Set to false to do nothing.
  *   Defaults to '\Cake\Network\Exception\UnauthorizedException'.
  *
  * @param \Cake\Controller\ComponentRegistry $registry The Component registry
  *   used on this request.
  * @param array $config Array of config to use.
  */
 public function __construct(ComponentRegistry $registry, $config)
 {
     $this->config(['header' => 'authorization', 'prefix' => 'bearer', 'parameter' => 'token', 'allowedAlgs' => ['HS256'], 'queryDatasource' => true, 'fields' => ['username' => 'id'], 'unauthenticatedException' => '\\Cake\\Network\\Exception\\UnauthorizedException']);
     parent::__construct($registry, $config);
 }
 /**
  * Constructor
  *
  * @param \Cake\Controller\ComponentRegistry $registry The Component registry
  *   used on this request.
  * @param array $config Array of config to use.
  */
 public function __construct(ComponentRegistry $registry, $config)
 {
     $this->config(['fields' => ['provider' => 'provider', 'openid_identifier' => 'openid_identifier', 'email' => 'email'], 'profileModel' => 'ADmad/HybridAuth.SocialProfiles', 'profileModelFkField' => 'user_id', 'hauth_return_to' => null]);
     parent::__construct($registry, $config);
 }
Beispiel #17
0
 /**
  * Constructor
  *
  * @param \Cake\Controller\ComponentRegistry $registry The Component registry used on this request.
  * @param array $config Array of config to use.
  * @throws \Exception
  */
 public function __construct(ComponentRegistry $registry, array $config = [])
 {
     $config = $this->normalizeConfig($config);
     parent::__construct($registry, $config);
 }