Subversion Repositories Applications.wikini

Rev

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

Rev 63 Rev 65
Line 4... Line 4...
4
	private $wiki = null;
4
	private $wiki = null;
5
	private $config = null;
5
	private $config = null;
Line 6... Line 6...
6
 
6
 
7
	private $cookie_tentative_identification = "";
7
	private $cookie_tentative_identification = "";
-
 
8
	private $delai_tentative_identification = 60;
-
 
9
	
Line 8... Line 10...
8
	private $delai_tentative_identification = 60;
10
	private $auth_header = 'Authorization';
9
 
11
 
10
	public function __construct($wiki) {
12
	public function __construct($wiki) {
-
 
13
		$this->wiki = $wiki;
11
		$this->wiki = $wiki;
14
		$this->config = $wiki->config;
12
		$this->config = $wiki->config;
15
		$this->auth_header = !empty($this->config['sso_auth_header']) ? $this->config['sso_auth_header'] : $this->auth_header;
Line 13... Line 16...
13
		$this->cookie_tentative_identification = 'wikini_sso_tentative_identification';
16
		$this->cookie_tentative_identification = 'wikini_sso_tentative_identification';
14
	}
17
	}
15
 
18
 
16
	function getToken() {
19
	function getToken() {
-
 
20
		// Premier essai, dans le header
-
 
21
		$headers = @apache_request_headers();
-
 
22
		$token = !empty($headers['Authorization']) ? $headers['Authorization'] : null;
-
 
23
		// Eventuellement, le jeton a pu être passé dans un header non standard, comme dans 
-
 
24
		// le cas où le header Authorization est supprimé par le mod cgi d'apache
-
 
25
		// Dans ce cas là on vérifie aussi dans un header alternatif si celui ci a été renseigné
Line 17... Line 26...
17
		// Premier essai, dans le header
26
		if($token == null && $this->auth_header != 'Authorization') {
18
		$headers = @apache_request_headers();
27
			$token = !empty($headers[$this->auth_header]) ? $headers[$this->auth_header] : null;
19
		$token = !empty($headers['Authorization']) ? $headers['Authorization'] : null;
28
		}
20
 
29
 
Line 136... Line 145...
136
				}
145
				}
137
			}
146
			}
138
		}
147
		}
139
	}
148
	}
Line -... Line 149...
-
 
149
 
-
 
150
	function recupererIdentiteConnecteePourApi() {		
-
 
151
		$token = $this->getToken();
-
 
152
		if($token != null) {
-
 
153
			// On demande à l'annuaire si le jeton est bien valide
-
 
154
			$jeton_rafraichi = json_decode(file_get_contents($this->wiki->config['sso_url'].'rafraichir?token='.$token), true);
-
 
155
			$nom_wiki = $this->verifierEtInsererUtilisateurParJeton($jeton_rafraichi);
-
 
156
			$token_decode = $this->decoderToken($jeton_rafraichi['token']);
-
 
157
			$this->wiki->SetUser($this->wiki->LoadUser($nom_wiki));
-
 
158
		}
Line 140... Line 159...
140
 
159
	}
141
 
160
 
142
	function connecterUtilisateur($login, $pass, $url_redirect = null) {
161
	function connecterUtilisateur($login, $pass, $url_redirect = null) {
143
		if(strpos($login, '@') === false) {
162
		if(strpos($login, '@') === false) {