Subversion Repositories Applications.annuaire

Rev

Rev 561 | Rev 571 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 561 Rev 565
Line 349... Line 349...
349
	protected function getUtilisateur() {
349
	protected function getUtilisateur() {
350
		return (isset($_SESSION['coel_utilisateur']) ? $_SESSION['coel_utilisateur'] : '');
350
		return (isset($_SESSION['coel_utilisateur']) ? $_SESSION['coel_utilisateur'] : '');
351
	}
351
	}
Line 352... Line 352...
352
 
352
 
-
 
353
	protected function authentifier() {
353
	protected function authentifier() {
354
		// @TODO @WARNING @ACHTUNG @ ALARM enlever le patch CGI quand on aura mis à jour Apache/PHP !!
354
		if (JRest::$cgi === false) { // si on est en CGI, accès libre pour tous (pas trouvé mieux)
355
		if (JRest::$cgi === false) { // si on est en CGI, accès libre pour tous (pas trouvé mieux)
355
			if (!isset($_SERVER['PHP_AUTH_USER'])) {
356
			if (!isset($_SERVER['PHP_AUTH_USER'])) {
356
				header('WWW-Authenticate: Basic realm="www.tela-botanica.org"');
357
				header('WWW-Authenticate: Basic realm="www.tela-botanica.org"');
357
				header('HTTP/1.0 401 Unauthorized');
358
				header('HTTP/1.0 401 Unauthorized');
Line 370... Line 371...
370
				}
371
				}
371
			}
372
			}
372
		}
373
		}
373
	}
374
	}
Line -... Line 375...
-
 
375
 
-
 
376
	/**
-
 
377
	 * Vérifie l'accès en se basant sur $id et $mdp si ceux-ci sont fournis; sinon,
-
 
378
	 * lit les valeurs transmises par l'authentification HTTP BASIC AUTH
374
 
379
	 */
-
 
380
	protected function verifierAcces($id = null, $mdp = null) {
375
	protected function verifierAcces($id = null, $mdp = null) {
381
		$basicAuth = false;
376
		if (JRest::$cgi === false) { // si on est en CGI, accès libre pour tous (pas trouvé mieux)
382
		if ($id == null && $mdp == null) {
377
			$id = is_null($id) ? $_SERVER['PHP_AUTH_USER'] : $id;
383
			$id = is_null($id) ? $_SERVER['PHP_AUTH_USER'] : $id;
-
 
384
			$mdp = is_null($mdp) ? $_SERVER['PHP_AUTH_PW'] : $mdp;
-
 
385
			$basicAuth = true;			
-
 
386
		}
378
			$mdp = is_null($mdp) ? $_SERVER['PHP_AUTH_PW'] : $mdp;
387
		if ($basicAuth === false || JRest::$cgi === false) { // en mode non-CGI ou pour une identification $id / $mdp
379
	
388
 
380
			$requete = 'SELECT '.$this->config['database_ident']['ann_id'].' AS courriel '.
389
			$requete = 'SELECT '.$this->config['database_ident']['ann_id'].' AS courriel '.
381
				'FROM '.$this->config['database_ident']['database'].'.'.$this->config['database_ident']['annuaire'].' '.
390
				'FROM '.$this->config['database_ident']['database'].'.'.$this->config['database_ident']['annuaire'].' '.
382
				'WHERE '.$this->config['database_ident']['ann_id'].' = '.$this->bdd->quote($id).' '.
391
				'WHERE '.$this->config['database_ident']['ann_id'].' = '.$this->bdd->quote($id).' '.
383
				'	AND '.$this->config['database_ident']['ann_pwd'].' = '.$this->config['database_ident']['pass_crypt_funct'].'('.$this->bdd->quote($mdp).')' ;
392
				'	AND '.$this->config['database_ident']['ann_pwd'].' = '.$this->config['database_ident']['pass_crypt_funct'].'('.$this->bdd->quote($mdp).')' ;
384
			
393
 
Line 385... Line 394...
385
			$resultat = $this->bdd->query($requete)->fetch();
394
			$resultat = $this->bdd->query($requete)->fetch();
386
	
395
	
387
			$identifie = false;
396
			$identifie = false;
388
			if (isset($resultat['courriel'])) {
397
			if (isset($resultat['courriel'])) {
389
				$identifie = true;
398
				$identifie = true;
390
			}
399
			}
391
			return $identifie;
400
			return $identifie;
392
		} else {
401
		} else { // si on est en CGI, accès libre pour tous (pas trouvé mieux)
393
			return true; // ça fait un peu mal...
402
			return true; // ça fait un peu mal...
Line 394... Line 403...
394
		}
403
		}
Line 401... Line 410...
401
	 * En cas d'erreur, sort du programme avec un entête HTTP 401
410
	 * En cas d'erreur, sort du programme avec un entête HTTP 401
402
	 * @TODO redondant avec les trucs du dessus :'(
411
	 * @TODO redondant avec les trucs du dessus :'(
403
	 */
412
	 */
404
	protected function authentificationHttpSimple() {
413
	protected function authentificationHttpSimple() {
405
		$autorise = true;
414
		$autorise = true;
406
		// contrôle d'accès
415
		// contrôle d'accès @TODO @WARNING @ACHTUNG @ ALARM enlever le patch CGI quand on aura mis à jour Apache/PHP !!
407
		if (JRest::$cgi === false) { // si on est en CGI, accès libre pour tous (pas trouvé mieux)
416
		if (JRest::$cgi === false) { // si on est en CGI, accès libre pour tous (pas trouvé mieux)
408
			$nomUtil = $_SERVER['PHP_AUTH_USER'];
417
			$nomUtil = $_SERVER['PHP_AUTH_USER'];
409
			$mdp = $_SERVER['PHP_AUTH_PW'];
418
			$mdp = $_SERVER['PHP_AUTH_PW'];
410
			$autorise = (($nomUtil == $this->config['database_ident']['username']) && ($mdp == $this->config['database_ident']['password']));
419
			$autorise = (($nomUtil == $this->config['database_ident']['username']) && ($mdp == $this->config['database_ident']['password']));
411
		}
420
		}