/trunk/jrest/services/Utilisateur.php |
---|
445,7 → 445,7 |
} |
/** |
* Permet d'identifier un utilisateur. |
* Permet d'identifier un utilisateur, sans utiliser SSO (à l'ancienne). |
* RESSOURCE : /utilisateur |
* POST : |
* - methode = 'connexion' : methode doit valoir 'connexion' pour connecter l'utilisateur. |
/trunk/jrest/bibliotheque/JRestService.php |
---|
351,6 → 351,7 |
} |
protected function authentifier() { |
if (JRest::$cgi === false) { // si on est en CGI, accès libre pour tous (pas trouvé mieux) |
if (!isset($_SERVER['PHP_AUTH_USER'])) { |
header('WWW-Authenticate: Basic realm="www.tela-botanica.org"'); |
header('HTTP/1.0 401 Unauthorized'); |
369,8 → 370,10 |
} |
} |
} |
} |
protected function verifierAcces($id = null, $mdp = null) { |
if (JRest::$cgi === false) { // si on est en CGI, accès libre pour tous (pas trouvé mieux) |
$id = is_null($id) ? $_SERVER['PHP_AUTH_USER'] : $id; |
$mdp = is_null($mdp) ? $_SERVER['PHP_AUTH_PW'] : $mdp; |
386,7 → 389,10 |
$identifie = true; |
} |
return $identifie; |
} else { |
return true; // ça fait un peu mal... |
} |
} |
/** |
* Envoie une demande d'authentification HTTP puis compare le couple |
398,9 → 404,11 |
protected function authentificationHttpSimple() { |
$autorise = true; |
// contrôle d'accès |
if (JRest::$cgi === false) { // si on est en CGI, accès libre pour tous (pas trouvé mieux) |
$nomUtil = $_SERVER['PHP_AUTH_USER']; |
$mdp = $_SERVER['PHP_AUTH_PW']; |
$autorise = (($nomUtil == $this->config['database_ident']['username']) && ($mdp == $this->config['database_ident']['password'])); |
} |
// entêtes HTTP |
if (! $autorise) { |
header('WWW-Authenticate: Basic realm="Annuaire de Tela Botanica"'); |
/trunk/jrest/JRest.php |
---|
23,6 → 23,9 |
/** Identifiant unique resource. */ |
private $uid = NULL; |
/** True si le type d'api est CGI / FastCGI, false si on a un module Apache... ou autre ? */ |
public static $cgi; |
/** |
* Constructor. Parses the configuration file "JRest.ini", grabs any request data sent, records the HTTP |
* request method used and parses the request URL to find out the requested resource |
63,6 → 66,10 |
} |
} |
// détection du type d'API : CGI ou module Apache - le CGI ne permet pas |
// d'utiliser l'authentification HTTP Basic :-( |
self::$cgi = substr(php_sapi_name(), 0, 3) == 'cgi'; |
$this->method = $_SERVER['REQUEST_METHOD']; |
} else { |
trigger_error('I require the server variables REQUEST_URI, REQUEST_METHOD and QUERY_STRING to work.', E_USER_ERROR); |
261,11 → 268,13 |
* Send a HTTP 401 response header. |
*/ |
private function unauthorized($realm = 'JRest') { |
if (self::$cgi === false) { // si on est en CGI, accès libre pour tous (pas trouvé mieux) |
if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW'])) { |
header('WWW-Authenticate: Basic realm="'.$realm.'"'); |
} |
header('HTTP/1.0 401 Unauthorized'); |
} |
} |
/** |
* Send a HTTP 404 response header. |
/trunk |
---|
Property changes: |
Modified: svn:mergeinfo |
Merged /branches/v1.4-baleine:r560 |