186,12 → 186,13 |
// Récupération de l'id et email de l'utilisateur connecté |
$tokenInfos = $this->decodeToken($cookie); |
|
$service = "auth/identite?token="; |
$url = sprintf($this->config['chemins']['baseURLServicesAnnuaireTpl'], $service).$cookie; |
|
$json = $this->getDao()->consulter($url); |
$token = json_decode($json, true)['token']; |
|
$token = $this->refreshToken($cookie)['token']; |
// $service = "auth/identite?token="; |
// $url = sprintf($this->config['chemins']['baseURLServicesAnnuaireTpl'], $service).$cookie; |
// |
// $json = $this->getDao()->consulter($url); |
// $token = json_decode($json, true)['token']; |
|
$user = [ |
'id' => $tokenInfos['id'], |
'email' => $tokenInfos['sub'], |
202,7 → 203,45 |
} |
|
} |
|
protected function refreshToken($token) { |
// $verificationServiceURL = 'https://www.tela-botanica.org/service:annuaire:auth/identite'; |
$service = "auth/identite?token=" . $token; |
$verificationServiceURL = sprintf($this->config['chemins']['baseURLServicesAnnuaireTpl'], $service); |
// $verificationServiceURL .= "?token=" . $token; |
$ch = curl_init(); |
// $timeout = 5; |
$cookie = 'tb_auth='.$token; |
|
$headr = array(); |
$headr[] = 'Cookie: ' . $cookie; |
$headr[] = 'Authorization: '.$token; |
|
curl_setopt($ch, CURLOPT_URL, $verificationServiceURL); |
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET'); |
curl_setopt($ch, CURLOPT_HTTPHEADER,$headr); |
// curl_setopt($ch, CURLOPT_HTTPHEADER, [ |
// 'Cookie: ' . $cookie, |
// ]); |
curl_setopt($ch, CURLOPT_COOKIE, $cookie); |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
// curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); |
// équivalent de "-k" |
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
$response = curl_exec($ch); |
|
// if ($response === false) { |
// echo 'Erreur cURL : ' . curl_error($ch); |
// } else { |
// echo 'Réponse : ' . $response; |
// } |
|
curl_close($ch); |
|
return json_decode($response, true); |
} |
|
protected function authentifierAdmin() { |
$message_accueil = "Veuillez vous identifier avec votre compte Tela Botanica."; |
$message_echec = "Accès limité aux administrateurs du CEL.\n". |