+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2006 Polytechnique.org *
- * http://opensource.polytechnique.org/ *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- ***************************************************************************/
-
-require_once("xorg.inc.php");
-new_skinned_page('index.tpl',AUTH_COOKIE);
-
-redirect(Env::get('dest', '/'));
-?>
--- /dev/null
+<?php
+/***************************************************************************
+ * Copyright (C) 2003-2006 Polytechnique.org *
+ * http://opensource.polytechnique.org/ *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., *
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
+ ***************************************************************************/
+
+class AuthModule extends PLModule
+{
+ function handlers()
+ {
+ return array(
+ 'auth-redirect.php' => $this->make_hook('redirect', AUTH_COOKIE),
+ 'auth-groupex.php' => $this->make_hook('groupex', AUTH_COOKIE),
+ );
+ }
+
+ function handler_redirect(&$page)
+ {
+ redirect(Env::get('dest', '/'));
+ }
+
+ function handler_groupex(&$page)
+ {
+ global $globals;
+
+ require_once dirname(__FILE__).'/auth/methods.inc.php';
+
+ $gpex_pass = $_GET["pass"];
+ $gpex_url = urldecode($_GET["url"]);
+ if (strpos($gpex_url, '?') === false) {
+ $gpex_url .= "?PHPSESSID=" . $_GET["session"];
+ } else {
+ $gpex_url .= "&PHPSESSID=" . $_GET["session"];
+ }
+
+ /* a-t-on besoin d'ajouter le http:// ? */
+ if (!preg_match("/^(http|https):\/\/.*/",$gpex_url))
+ $gpex_url = "http://$gpex_url";
+ $gpex_challenge = $_GET["challenge"];
+
+ // mise à jour de l'heure et de la machine de dernier login sauf quand on est en suid
+ if (!isset($_SESSION['suid'])) {
+ $logger = (isset($_SESSION['log']) && $_SESSION['log']->uid == $uid)
+ ? $_SESSION['log']
+ : new DiogenesCoreLogger($uid);
+ $logger->log('connexion_auth_ext', $_SERVER['PHP_SELF']);
+ }
+
+ /* on parcourt les entrees de groupes_auth */
+ $res = $globals->xdb->iterRow('select privkey,name,datafields from groupesx_auth');
+
+ while (list($privkey,$name,$datafields) = $res->next()) {
+ if (md5($gpex_challenge.$privkey) == $gpex_pass) {
+ $returl = $gpex_url.gpex_make_params($gpex_challenge,$privkey,$datafields);
+ redirect($returl);
+ }
+ }
+
+ /* si on n'a pas trouvé, on renvoit sur x.org */
+ redirect('https://www.polytechnique.org/');
+ }
+}
+
+?>
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-$gpex_pass = $_GET["pass"];
-$gpex_url = urldecode($_GET["url"]);
-if (strpos($gpex_url, '?') === false) {
- $gpex_url .= "?PHPSESSID=" . $_GET["session"];
-} else {
- $gpex_url .= "&PHPSESSID=" . $_GET["session"];
-}
-/* a-t-on besoin d'ajouter le http:// ? */
-if (!preg_match("/^(http|https):\/\/.*/",$gpex_url))
- $gpex_url = "http://$gpex_url";
-$gpex_challenge = $_GET["challenge"];
-
-require_once("xorg.inc.php");
-new_skinned_page('index.tpl',AUTH_COOKIE);
-
-// mise à jour de l'heure et de la machine de dernier login sauf quand on est en suid
-if (!isset($_SESSION['suid'])) {
- $logger = (isset($_SESSION['log']) && $_SESSION['log']->uid==$uid) ? $_SESSION['log'] : new DiogenesCoreLogger($uid);
- $logger->log("connexion_auth_ext",$_SERVER['PHP_SELF']);
-}
-
/* cree le champs "auth" renvoye au Groupe X */
function gpex_make_auth($chlg, $privkey, $datafields) {
global $globals;
$fieldarr = explode(",",$datafields);
$tohash = "1$chlg$privkey";
- $res = $globals->xdb->query("SELECT matricule,matricule_ax,promo,promo_sortie,flags,deces,nom,prenom,nationalite,section,naissance FROM auth_user_md5 WHERE user_id = {?}", Session::getInt('uid'));
+ $res = $globals->xdb->query("SELECT matricule, matricule_ax, promo,
+ promo_sortie, flags, deces, nom,
+ prenom, nationalite, section,
+ naissance
+ FROM auth_user_md5 WHERE user_id = {?}",
+ Session::getInt('uid'));
$personnal_data = $res->fetchOneAssoc();
-
- while (list(,$val) = each($fieldarr)) {
- /* on verifie qu'on n'a pas demandé une
- variable inexistante ! */
- if (isset($_SESSION[$val])) {
- $tohash .= $_SESSION[$val];
+
+ foreach ($fieldarr as $val) {
+ /* on verifie qu'on n'a pas demandé une variable inexistante ! */
+ if (Session::has($val)) {
+ $tohash .= Session::get($val);
} else if (isset($personnal_data[$val])) {
$tohash .= $personnal_data[$val];
} else if ($val == 'username') {
- $res = $globals->xdb->query("SELECT alias FROM aliases WHERE id = {?} AND FIND_IN_SET('bestalias', flags)", Session::getInt('uid'));
+ $res = $globals->xdb->query("SELECT alias FROM aliases
+ WHERE id = {?} AND FIND_IN_SET('bestalias', flags)",
+ Session::getInt('uid'));
$min_username = $res->fetchOneCell();
$tohash .= $min_username;
- }
+ }
}
$tohash .= "1";
return md5($tohash);
function gpex_make_params($chlg, $privkey, $datafields) {
global $globals;
$params = "&auth=".gpex_make_auth($chlg, $privkey, $datafields);
-
- $res = $globals->xdb->query("SELECT matricule,matricule_ax,promo,promo_sortie,flags,deces,nom,prenom,nationalite,section,naissance FROM auth_user_md5 WHERE user_id = {?}", Session::getInt('uid'));
+
+ $res = $globals->xdb->query("SELECT matricule, matricule_ax, promo,
+ promo_sortie, flags, deces, nom,
+ prenom, nationalite, section,
+ naissance
+ FROM auth_user_md5 WHERE user_id = {?}",
+ Session::getInt('uid'));
$personnal_data = $res->fetchOneAssoc();
-
+
$fieldarr = explode(",",$datafields);
- while (list(,$val) = each($fieldarr)) {
- if (isset($_SESSION[$val])) {
- $params .= "&$val=".$_SESSION[$val];
+
+ foreach ($fieldarr as $val) {
+ if (Session::has($val)) {
+ $tohash .= Session::get($val);
} else if (isset($personnal_data[$val])) {
$params .= "&$val=".$personnal_data[$val];
} else if ($val == 'username') {
- $res = $globals->xdb->query("SELECT alias FROM aliases WHERE id = {?} AND FIND_IN_SET('bestalias', flags)", Session::getInt('uid'));
+ $res = $globals->xdb->query("SELECT alias FROM aliases
+ WHERE id = {?} AND FIND_IN_SET('bestalias', flags)",
+ Session::getInt('uid'));
$min_username = $res->fetchOneCell();
$params .= "&$val=".$min_username;
- }
+ }
}
return $params;
}
-/* on parcourt les entrees de groupes_auth */
-$res = $globals->xdb->iterRow('select privkey,name,datafields from groupesx_auth');
-
-while (list($privkey,$name,$datafields) = $res->next()) {
- if (md5($gpex_challenge.$privkey) == $gpex_pass) {
- $returl = $gpex_url.gpex_make_params($gpex_challenge,$privkey,$datafields);
- redirect($returl);
- }
-}
-
-/* si on n'a pas trouvé, on renvoit sur x.org */
-redirect('https://www.polytechnique.org/');
-
?>