2 /***************************************************************************
3 * Copyright (C) 2003-2006 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
22 class AuthModule
extends PLModule
27 'auth-redirect.php' => $this->make_hook('redirect', AUTH_COOKIE
),
28 'auth-groupex.php' => $this->make_hook('groupex', AUTH_COOKIE
),
32 function handler_redirect(&$page)
34 redirect(Env
::get('dest', '/'));
37 function handler_groupex(&$page)
41 require_once dirname(__FILE__
).'/auth/methods.inc.php';
43 $gpex_pass = $_GET["pass"];
44 $gpex_url = urldecode($_GET["url"]);
45 if (strpos($gpex_url, '?') === false
) {
46 $gpex_url .= "?PHPSESSID=" . $_GET["session"];
48 $gpex_url .= "&PHPSESSID=" . $_GET["session"];
51 /* a-t-on besoin d'ajouter le http:// ? */
52 if (!preg_match("/^(http|https):\/\/.*/",$gpex_url))
53 $gpex_url = "http://$gpex_url";
54 $gpex_challenge = $_GET["challenge"];
56 // mise à jour de l'heure et de la machine de dernier login sauf quand on est en suid
57 if (!isset($_SESSION['suid'])) {
58 $logger = (isset($_SESSION['log']) && $_SESSION['log']->uid
== $uid)
60 : new DiogenesCoreLogger($uid);
61 $logger->log('connexion_auth_ext', $_SERVER['PHP_SELF']);
64 /* on parcourt les entrees de groupes_auth */
65 $res = $globals->xdb
->iterRow('select privkey,name,datafields from groupesx_auth');
67 while (list($privkey,$name,$datafields) = $res->next()) {
68 if (md5($gpex_challenge.$privkey) == $gpex_pass) {
69 $returl = $gpex_url.gpex_make_params($gpex_challenge,$privkey,$datafields);
74 /* si on n'a pas trouvé, on renvoit sur x.org */
75 redirect('https://www.polytechnique.org/');