/trunk/api/bibliotheque/WikiApi.php |
---|
2,7 → 2,7 |
class WikiApi { |
private $page = null; |
private $wikiObjet = null; |
public $wikiObjet = null; |
private $cheminWiki = null; |
private $cheminApi = null; |
/trunk/api/rest/modules/0.5/Pages.php |
---|
33,12 → 33,18 |
public function __construct($config) { |
parent::__construct($config); |
$this->wiki = Registre::get('wikiApi'); |
// La variable globale wiki est déclarée par les wiki et leurs plugins |
// un bug lié à certains plugin impose de la redéclarer et la réaffecter |
global $wiki; |
$this->wiki = Registre::get('wikiApi'); |
// La variable globale wiki est déclarée par les wiki et leurs plugins |
// un bug lié à certains plugin impose de la redéclarer et la réaffecter |
global $wiki; |
$wiki = $this->wiki; |
// C'est moche mais normalement déterministe comme chemin de fichier |
require_once realpath(dirname(__FILE__).'/../../../../tools/login/libs/identificationsso.class.php'); |
// Attention la classe de sso s'instancie avec le vrai objet wiki contenu dans wikiApi |
$identification = new IdentificationSso($this->wiki->wikiObjet); |
$identification->recupererIdentiteConnecteePourApi(); |
require_once realpath(dirname(__FILE__).'/../../../bibliotheque/ManipulationPage.php'); |
$this->manipulationPage = new ManipulationPage($this->wiki, $this->pageNom); |
} |
/trunk/tools/login/README.txt |
---|
4,4 → 4,8 |
il faut ajouter deux variables de configuration au wiki : |
sso_url => 'https://localhost/annuaire/jrest/auth/' |
use_sso => '1' |
use_sso => '1' |
Eventuellement si le serveur ne supporte pas la variable Authorization |
dans un header, le nom du header peut être changé en ajoutant ce paramètre : |
sso_auth_header => 'Auth' |
/trunk/tools/login/libs/identificationsso.class.php |
---|
6,10 → 6,13 |
private $cookie_tentative_identification = ""; |
private $delai_tentative_identification = 60; |
private $auth_header = 'Authorization'; |
public function __construct($wiki) { |
$this->wiki = $wiki; |
$this->config = $wiki->config; |
$this->auth_header = !empty($this->config['sso_auth_header']) ? $this->config['sso_auth_header'] : $this->auth_header; |
$this->cookie_tentative_identification = 'wikini_sso_tentative_identification'; |
} |
17,6 → 20,12 |
// Premier essai, dans le header |
$headers = @apache_request_headers(); |
$token = !empty($headers['Authorization']) ? $headers['Authorization'] : null; |
// Eventuellement, le jeton a pu être passé dans un header non standard, comme dans |
// le cas où le header Authorization est supprimé par le mod cgi d'apache |
// Dans ce cas là on vérifie aussi dans un header alternatif si celui ci a été renseigné |
if($token == null && $this->auth_header != 'Authorization') { |
$token = !empty($headers[$this->auth_header]) ? $headers[$this->auth_header] : null; |
} |
// Sinon dans $_REQUEST ? |
if($token == null) { |
138,6 → 147,16 |
} |
} |
function recupererIdentiteConnecteePourApi() { |
$token = $this->getToken(); |
if($token != null) { |
// On demande à l'annuaire si le jeton est bien valide |
$jeton_rafraichi = json_decode(file_get_contents($this->wiki->config['sso_url'].'rafraichir?token='.$token), true); |
$nom_wiki = $this->verifierEtInsererUtilisateurParJeton($jeton_rafraichi); |
$token_decode = $this->decoderToken($jeton_rafraichi['token']); |
$this->wiki->SetUser($this->wiki->LoadUser($nom_wiki)); |
} |
} |
function connecterUtilisateur($login, $pass, $url_redirect = null) { |
if(strpos($login, '@') === false) { |