Subversion Repositories Applications.reseau

Rev

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

Rev 90 Rev 100
Line 178... Line 178...
178
	$('#nom-complet').html(nomComplet);
178
	$('#nom-complet').html(nomComplet);
179
	$('#nom-complet').attr('title', email);
179
	$('#nom-complet').attr('title', email);
180
}
180
}
Line 181... Line 181...
181
 
181
 
-
 
182
/**
-
 
183
 * Décodage "url-safe" des chaînes base64 retournées par le SSO (lib jwt)
-
 
184
 */
-
 
185
function b64d(input) {
-
 
186
	var remainder = input.length % 4;
-
 
187
	if (remainder != 0) {
-
 
188
		var padlen = 4 - remainder;
-
 
189
		for (var i=0; i < padlen; i++) {
-
 
190
			input += '=';
-
 
191
		}
-
 
192
	}
-
 
193
	input = input.replace('-', '+');
-
 
194
	input = input.replace('_', '/');
-
 
195
	return atob(input);
-
 
196
}
-
 
197
 
182
/**
198
/**
183
 * Décodage à l'arrache d'un jeton JWT, ATTENTION CONSIDERE QUE LE
199
 * Décodage à l'arrache d'un jeton JWT, ATTENTION CONSIDERE QUE LE
184
 * JETON EST VALIDE, ne pas décoder n'importe quoi - pas trouvé de lib simple
-
 
185
 * Si pb de cross-browser, tenter ceci : https://code.google.com/p/javascriptbase64/
-
 
186
 * ou ceci : https://code.google.com/p/crypto-js
200
 * JETON EST VALIDE, ne pas décoder n'importe quoi - pas trouvé de lib simple
187
 */
201
 */
188
function decoderJeton(jeton) {
202
function decoderJeton(jeton) {
189
	parts = jeton.split('.');
203
	parts = jeton.split('.');
-
 
204
	payload = parts[1];
190
	payload = parts[1];
205
 
191
	payload = atob(payload);
206
	payload = b64d(payload);
Line 192... Line 207...
192
	payload = JSON.parse(payload, true);
207
	payload = JSON.parse(payload, true);
193
 
208