Example #1
0
 /**
  * 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);
     $cfgHelper = SimpleSAML_Configuration::loadFromArray($config, 'Authentication source ' . var_export($this->authId, TRUE));
     $this->orgs = array();
     $this->ldapOrgs = array();
     foreach ($config as $name => $value) {
         if ($name === 'username_organization_method') {
             $usernameOrgMethod = $cfgHelper->getValueValidate('username_organization_method', array('none', 'allow', 'force'));
             $this->setUsernameOrgMethod($usernameOrgMethod);
             continue;
         }
         if ($name === 'include_organization_in_username') {
             $this->includeOrgInUsername = $cfgHelper->getBoolean('include_organization_in_username', FALSE);
             continue;
         }
         $orgCfg = $cfgHelper->getArray($name);
         $orgId = $name;
         if (array_key_exists('description', $orgCfg)) {
             $this->orgs[$orgId] = $orgCfg['description'];
         } else {
             $this->orgs[$orgId] = $orgId;
         }
         $orgCfg = new sspmod_ldap_ConfigHelper($orgCfg, 'Authentication source ' . var_export($this->authId, TRUE) . ', organization ' . var_export($orgId, TRUE));
         $this->ldapOrgs[$orgId] = $orgCfg;
     }
 }
Example #2
0
    /**
     * 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('required_statut', $config)) {
            $this->requiredStatut = $config['required_statut'];
        }
    }
} elseif (isset($state['core:organization'])) {
    $organization = (string) $state['core:organization'];
} else {
    $organization = '';
}
$errorCode = NULL;
if ($organizations === NULL || !empty($organization)) {
    if (!empty($username) && !empty($password)) {
        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;
            setcookie($source->getAuthId() . '-username', $username, $params['expire'], $params['path'], $params['domain'], $params['secure'], $params['httponly']);
        }
        $errorCode = sspmod_core_Auth_UserPassOrgBase::handleLogin($authStateId, $username, $password, $organization);
    }
}
$globalConfig = SimpleSAML_Configuration::getInstance();
$t = new SimpleSAML_XHTML_Template($globalConfig, 'core:loginuserpass.php');
$t->data['stateparams'] = array('AuthState' => $authStateId);
$t->data['username'] = $username;
$t->data['forceUsername'] = FALSE;
$t->data['rememberUsernameEnabled'] = $source->getRememberUsernameEnabled();
$t->data['rememberUsernameChecked'] = $source->getRememberUsernameChecked();
if (isset($_COOKIE[$source->getAuthId() . '-username'])) {
    $t->data['rememberUsernameChecked'] = TRUE;
}
$t->data['errorcode'] = $errorCode;
if ($organizations !== NULL) {
    $t->data['selectedOrg'] = $organization;
Example #4
0
 /**
  * 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);
     $cfgHelper = SimpleSAML_Configuration::loadFromArray($config, 'Authentication source ' . var_export($this->authId, TRUE));
     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);
         }
     }
 }