/** * Constructor for this authentication source. * * @param array $info Information about this authentication source. * @param array $config Configuration. */ public function __construct($info, $config) { assert('is_array($info)'); assert('is_array($config)'); // Call the parent constructor first, as required by the interface parent::__construct($info, $config); // Parse configuration. $config = SimpleSAML_Configuration::loadFromArray($config, 'Authentication source ' . var_export($this->authId, true)); $this->servers = $config->getArray('servers', array()); /* For backwards compatibility. */ if (empty($this->servers)) { $this->hostname = $config->getString('hostname'); $this->port = $config->getIntegerRange('port', 1, 65535, 1812); $this->secret = $config->getString('secret'); $this->servers[] = array('hostname' => $this->hostname, 'port' => $this->port, 'secret' => $this->secret); } $this->timeout = $config->getInteger('timeout', 5); $this->retries = $config->getInteger('retries', 3); $this->realm = $config->getString('realm', null); $this->usernameAttribute = $config->getString('username_attribute', null); $this->nasIdentifier = $config->getString('nas_identifier', \SimpleSAML\Utils\HTTP::getSelfHost()); $this->vendor = $config->getInteger('attribute_vendor', null); if ($this->vendor !== null) { $this->vendorType = $config->getInteger('attribute_vendor_type'); } }
/** * Constructor for this authentication source. * * @param array $info Information about this authentication source. * @param array $config Configuration. */ public function __construct($info, $config) { assert('is_array($info)'); assert('is_array($config)'); // Call the parent constructor first, as required by the interface parent::__construct($info, $config); $this->users = array(); // Validate and parse our configuration foreach ($config as $userpass => $attributes) { if (!is_string($userpass)) { throw new Exception('Invalid <username>:<passwordhash> for authentication source ' . $this->authId . ': ' . $userpass); } $userpass = explode(':', $userpass, 2); if (count($userpass) !== 2) { throw new Exception('Invalid <username>:<passwordhash> for authentication source ' . $this->authId . ': ' . $userpass[0]); } $username = $userpass[0]; $passwordhash = $userpass[1]; try { $attributes = SimpleSAML\Utils\Attributes::normalizeAttributesArray($attributes); } catch (Exception $e) { throw new Exception('Invalid attributes for user ' . $username . ' in authentication source ' . $this->authId . ': ' . $e->getMessage()); } $this->users[$username . ':' . $passwordhash] = $attributes; } }
/** * Constructor for this authentication source. * * @param array $info Information about this authentication source. * @param array $config Configuration. */ public function __construct($info, $config) { assert('is_array($info)'); assert('is_array($config)'); /* Call the parent constructor first, as required by the interface. */ parent::__construct($info, $config); if (array_key_exists('privacyideaserver', $config)) { $this->privacyideaserver = $config['privacyideaserver']; } if (array_key_exists('realm', $config)) { $this->realm = $config['realm']; } if (array_key_exists('sslverifyhost', $config)) { $this->sslverifyhost = $config['sslverifyhost']; } if (array_key_exists('sslverifypeer', $config)) { $this->sslverifypeer = $config['sslverifypeer']; } if (array_key_exists('attributemap', $config)) { $this->attributemap = $config['attributemap']; } if (array_key_exists('otpextra', $config)) { $this->otp_extra = $config['otpextra']; } }
/** * Constructor for this authentication source. * * @param array $info Information about this authentication source. * @param array $config Configuration. */ public function __construct($info, $config) { assert('is_array($info)'); assert('is_array($config)'); /* Call the parent constructor first, as required by the interface. */ parent::__construct($info, $config); /* Parse configuration. */ $config = SimpleSAML_Configuration::loadFromArray($config, 'Authentication source ' . var_export($this->authId, TRUE)); $this->servers = $config->getArray('servers', array()); /* For backwards compatibility. */ if (empty($this->servers)) { $this->hostname = $config->getString('hostname'); $this->port = $config->getIntegerRange('port', 1, 65535, 1812); $this->secret = $config->getString('secret'); $this->servers[] = array('hostname' => $this->hostname, 'port' => $this->port, 'secret' => $this->secret); } $this->timeout = $config->getInteger('timeout', 5); $this->retries = $config->getInteger('retries', 3); $this->usernameAttribute = $config->getString('username_attribute', NULL); $this->nasIdentifier = $config->getString('nas_identifier', isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost'); $this->vendor = $config->getInteger('attribute_vendor', NULL); if ($this->vendor !== NULL) { $this->vendorType = $config->getInteger('attribute_vendor_type'); } }
/** * Constructor for this authentication source. * * @param array $info Information about this authentication source. * @param array $config Configuration. */ public function __construct($info, $config) { assert('is_array($info)'); assert('is_array($config)'); /* Call the parent constructor first, as required by the interface. */ parent::__construct($info, $config); $this->setForcedUsername("admin"); }
/** * Constructor for this authentication source. * * @param array $info Information about this authentication source. * @param array $config Configuration. */ public function __construct($info, $config) { assert('is_array($info)'); assert('is_array($config)'); /* Call the parent constructor first, as required by the interface. */ parent::__construct($info, $config); $this->ldapConfig = new sspmod_ldap_ConfigHelper($config, 'Authentication source ' . var_export($this->authId, TRUE)); }
public function __construct($info, $config) { parent::__construct($info, $config); $dsn = 'pgsql:host=%host%;port=%port%;dbname=%dbname%;user=%user%;password=%password%'; $camposConf = array('host', 'port', 'dbname', 'user', 'password'); foreach ($camposConf as $campo) { if (!isset($config[$campo])) { throw new Exception("No esta configurado el campo {$campo}"); } $dsn = str_replace("%{$campo}%", $config[$campo], $dsn); } $this->pdo = new PDO($dsn); }
public function __construct($info, $config) { parent::__construct($info, $config); $dsn = 'informix:client_locale=en_us.cp1252;service=1526;protocol=olsoctcp;EnableScrollableCursors=1'; $camposConf = array('LogonId', 'pwd', 'server', 'host', 'database'); foreach ($camposConf as $campo) { if (!isset($config[$campo])) { throw new Exception("No esta configurado el campo {$campo}"); } $dsn .= ";{$campo}={$config[$campo]}"; } $this->pdo = new PDO($dsn); }
/** * Constructor for this authentication source. * * @param array $info Information about this authentication source. * @param array $config Configuration. */ public function __construct($info, $config) { assert('is_array($info)'); assert('is_array($config)'); /* Call the parent constructor first, as required by the interface. */ parent::__construct($info, $config); $this->users = array(); if (!($htpasswd = file_get_contents($config['htpasswd_file']))) { throw new Exception('Could not read ' . $config['htpasswd_file']); } $this->users = explode("\n", trim($htpasswd)); try { $this->attributes = SimpleSAML_Utilities::parseAttributes($config['static_attributes']); } catch (Exception $e) { throw new Exception('Invalid static_attributes in authentication source ' . $this->authId . ': ' . $e->getMessage()); } }
/** * Constructor for this authentication source. * * @param array $info Information about this authentication source. * @param array $config Configuration. */ public function __construct($info, $config) { assert('is_array($info)'); assert('is_array($config)'); /* Call the parent constructor first, as required by the interface. */ parent::__construct($info, $config); /* Parse configuration. */ $config = SimpleSAML_Configuration::loadFromArray($config, 'Authentication source ' . var_export($this->authId, TRUE)); $this->hostname = $config->getString('hostname'); $this->port = $config->getIntegerRange('port', 1, 65535, 1812); $this->secret = $config->getString('secret'); $this->timeout = $config->getInteger('timeout', 5); $this->retries = $config->getInteger('retries', 3); $this->usernameAttribute = $config->getString('username_attribute', NULL); $this->vendor = $config->getInteger('attribute_vendor', NULL); if ($this->vendor !== NULL) { $this->vendorType = $config->getInteger('attribute_vendor_type'); } }
/** * Constructor for this authentication source. * * @param array $info Information about this authentication source. * @param array $config Configuration. */ public function __construct($info, $config) { assert('is_array($info)'); assert('is_array($config)'); /* Call the parent constructor first, as required by the interface. */ parent::__construct($info, $config); /* Make sure that all required parameters are present. */ foreach (array('dsn', 'username', 'password', 'query') as $param) { if (!array_key_exists($param, $config)) { throw new Exception('Missing required attribute \'' . $param . '\' for authentication source ' . $this->authId); } if (!is_string($config[$param])) { throw new Exception('Expected parameter \'' . $param . '\' for authentication source ' . $this->authId . ' to be a string. Instead it was: ' . var_export($config[$param], TRUE)); } } $this->dsn = $config['dsn']; $this->username = $config['username']; $this->password = $config['password']; $this->query = $config['query']; }
/** * Constructor for this authentication source. * * @param array $info Information about this authentication source. * @param array $config Configuration. */ public function __construct($info, $config) { assert('is_array($info)'); assert('is_array($config)'); /* Call the parent constructor first, as required by the interface. */ parent::__construct($info, $config); /* Make sure that all required parameters are present. */ foreach (array('dsn', 'username', 'password', 'table_user_name', 'hash') as $param) { if (!array_key_exists($param, $config)) { throw new Exception('Missing required attribute \'' . $param . '\' for authentication source ' . $this->authId); } if (!is_string($config[$param])) { throw new Exception('Expected parameter \'' . $param . '\' for authentication source ' . $this->authId . ' to be a string. Instead it was: ' . var_export($config[$param], TRUE)); } } $this->dsn = $config['dsn']; $this->username = $config['username']; $this->password = $config['password']; $this->table_user_name = $config['table_user_name']; $this->encoder = new Symfony\Component\Security\Core\Encoder\MessageDigestPasswordEncoder($config['hash']); }
/** * Constructor for this authentication source. * * @param array $info Information about this authentication source. * @param array $config Configuration. */ public function __construct($info, $config) { assert('is_array($info)'); assert('is_array($config)'); /* Call the parent constructor first, as required by the interface. */ parent::__construct($info, $config); /* Ensure that the krb5 PHP module is installed and loaded */ if (!extension_loaded('krb5')) { throw new Exception('Missing required PHP module krb5 for authentication source ' . $this->authId); } /* Make sure that all required parameters are present. */ foreach (array('realm') as $param) { if (!array_key_exists($param, $config)) { throw new Exception('Missing required attribute \'' . $param . '\' for authentication source ' . $this->authId); } if (!is_string($config[$param])) { throw new Exception('Expected parameter \'' . $param . '\' for authentication source ' . $this->authId . ' to be a string. Instead it was: ' . var_export($config[$param], TRUE)); } } $this->krb5 = new KRB5CCache(); $this->realm = '@' . $config['realm']; $this->stripRealm = $config['stripRealm']; }
/** * Constructor for this authentication source. * * @param array $info Information about this authentication source. * @param array $config Configuration. */ public function __construct($info, $config) { assert('is_array($info)'); assert('is_array($config)'); /* Call the parent constructor first, as required by the interface. */ parent::__construct($info, $config); /* Get the configuration for this module */ $drupalAuthConfig = new sspmod_drupalauth_ConfigHelper($config, 'Authentication source ' . var_export($this->authId, TRUE)); $this->debug = $drupalAuthConfig->getDebug(); $this->attributes = $drupalAuthConfig->getAttributes(); if (!defined('DRUPAL_ROOT')) { define('DRUPAL_ROOT', $drupalAuthConfig->getDrupalroot()); } /* Include the Drupal bootstrap */ //require_once(DRUPAL_ROOT.'/includes/common.inc'); require_once DRUPAL_ROOT . '/includes/bootstrap.inc'; require_once DRUPAL_ROOT . '/includes/file.inc'; /* Using DRUPAL_BOOTSTRAP_FULL means that SimpleSAMLphp must use an session storage * mechanism other than phpsession (see: store.type in config.php). However, this trade-off * prevents the need for hackery here and makes this module work better in different environments. */ drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); // we need to be able to call Drupal user function so we load some required modules drupal_load('module', 'system'); drupal_load('module', 'user'); drupal_load('module', 'field'); }
} if ($source->getRememberUsernameEnabled()) { $sessionHandler = SimpleSAML_SessionHandler::getSessionHandler(); $params = $sessionHandler->getCookieParams(); $params['expire'] = time(); $params['expire'] += isset($_REQUEST['remember_username']) && $_REQUEST['remember_username'] == 'Yes' ? 31536000 : -300; \SimpleSAML\Utils\HTTP::setCookie($source->getAuthId() . '-username', $username, $params, FALSE); } if ($source->isRememberMeEnabled()) { if (array_key_exists('remember_me', $_REQUEST) && $_REQUEST['remember_me'] === 'Yes') { $state['RememberMe'] = TRUE; $authStateId = SimpleSAML_Auth_State::saveState($state, sspmod_core_Auth_UserPassBase::STAGEID); } } try { sspmod_core_Auth_UserPassBase::handleLogin($authStateId, $username, $password); } catch (SimpleSAML_Error_Error $e) { /* Login failed. Extract error code and parameters, to display the error. */ $errorCode = $e->getErrorCode(); $errorParams = $e->getParameters(); } } $globalConfig = SimpleSAML_Configuration::getInstance(); $t = new SimpleSAML_XHTML_Template($globalConfig, 'core:loginuserpass.php'); $t->data['stateparams'] = array('AuthState' => $authStateId); if (array_key_exists('forcedUsername', $state)) { $t->data['username'] = $state['forcedUsername']; $t->data['forceUsername'] = TRUE; $t->data['rememberUsernameEnabled'] = FALSE; $t->data['rememberUsernameChecked'] = FALSE; $t->data['rememberMeEnabled'] = $source->isRememberMeEnabled();
/** * Constructor for this authentication source. * * @param array $info Information about this authentication source. * @param array $config Configuration. */ public function __construct($info, $config) { assert('is_array($info)'); assert('is_array($config)'); /* Call the parent constructor first, as required by the interface. */ parent::__construct($info, $config); $this->login_attributes = array(); $cfgHelper = SimpleSAML_Configuration::loadFromArray($config, 'Authentication source ' . var_export($this->authId, TRUE)); if (array_key_exists('merge_type', $config)) { $this->merge_type = $cfgHelper->getValueValidate('merge_type', array('first', 'allinone', 'custom')); } if (array_key_exists('username_organization_method', $config)) { $usernameOrgMethod = $cfgHelper->getValueValidate('username_organization_method', array('none', 'allow', 'force')); $this->setUsernameOrgMethod($usernameOrgMethod); } if (array_key_exists('username_organization_in_username', $config)) { $this->includeOrgInUsername = $cfgHelper->getBoolean('include_organization_in_username', FALSE); } if (!array_key_exists('sources', $config)) { throw new Exception('Missing required attribute \'sources \' for authentication source ' . $this->authId); } $this->orgs = array(); $this->sqlOrgs = array(); foreach ($config['sources'] as $name => $orgCfg) { if (is_array($orgCfg)) { $orgId = $name; if (array_key_exists('description', $orgCfg)) { $this->orgs[$orgId] = $orgCfg['description']; } else { $this->orgs[$orgId] = $orgId; } $this->sqlOrgs[$orgId] = new sspmod_sqlauth_Auth_Source_SQL($info, $orgCfg); } } }