Create an instance with the specified authsource.
public __construct ( string $authSource ) | ||
$authSource | string | The id of the authentication source. |
/** * Initialise une authentification en utilisant les paramêtre renseignés dans gepi * * @param string|NULL $auth The authentication source. Si non précisé, utilise la source configurée dans gepi. */ public function __construct($auth = null) { if ($auth == null) { if (isset($_SESSION['utilisateur_saml_source'])) { //on prend la source précisée précedemment en session. //Cela sert si le mode d'authentification a changé au cours de la session de l'utilisateur $auth = $_SESSION['utilisateur_saml_source']; } else { //on va sélectionner la source d'authentification gepi $path = dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))); include_once("$path/secure/connect.inc.php"); // Database connection require_once("$path/lib/mysql.inc"); require_once("$path/lib/settings.inc"); // Load settings if (!loadSettings()) { die("Erreur chargement settings"); } $auth = getSettingValue('auth_simpleSAML_source'); } } $config = SimpleSAML_Configuration::getOptionalConfig('authsources.php'); $sources = $config->getOptions(); if (!count($sources)) { echo 'Erreur simplesaml : Aucune source configurée dans le fichier authsources.php'; die; } if (!in_array($auth, $sources)) { //si la source précisée n'est pas trouvée, utilisation par défaut d'une source proposant tout les choix possible //(voir le fichier authsources.php) if ($auth == 'unset') { //l'admin a réglé la source à unset, ce n'est pas la peine de mettre un message d'erreur } else { echo 'Erreur simplesaml : source '.$auth.' non configurée. Utilisation par défaut de la source : «Authentification au choix entre toutes les sources configurees».'; } $auth = 'Authentification au choix entre toutes les sources configurees'; } //on utilise une variable en session pour se souvenir quelle est la source utilisé pour cette session. Utile pour le logout, si entretemps l'admin a changé la source d'authentification. $_SESSION['utilisateur_saml_source'] = $auth; //print_r($config);die; $this->authSourceConfig = $config->getArray($auth); assert('is_string($auth)'); $this->authSource = $auth; parent::__construct($auth); }
/** * Initialize a backwards-compatibility authsource for the given authentication page and authority. * * @param string $auth The authentication page. * @param string|NULL $authority The authority we should validate the login against. * @deprecated */ public function __construct($auth, $authority) { assert('is_string($auth)'); assert('is_string($authority) || is_null($authority)'); if ($authority === NULL) { $candidates = array('auth/login-admin.php' => 'login-admin', 'auth/login-cas-ldap.php' => 'login-cas-ldap', 'auth/login-ldapmulti.php' => 'login-ldapmulti', 'auth/login-radius.php' => 'login-radius', 'auth/login-tlsclient.php' => 'tlsclient', 'auth/login-wayf-ldap.php' => 'login-wayf-ldap', 'auth/login.php' => 'login'); if (!isset($candidates[$auth])) { throw new SimpleSAML_Error_Exception('You must provide an authority when using ' . $auth); } $authority = $candidates[$auth]; } $this->auth = $auth; $this->authority = $authority; parent::__construct($authority); }