6fea694c1170e256cbab61c9878a6b406dcee95d
3 require_once dirname(__FILE__
) . '/../../inc/core/class.dc.auth.php';
5 class xorgAuth
extends dcAuth
{
6 public $xorg_infos = array('forlife' => null
,
10 public function __construct(&$core) {
11 parent
::__construct($core);
14 private function buildFromSession() {
16 if (!isset($core) ||
!isset($core->session
)) {
19 $core->session
->start();
20 if (@$_SESSION['auth-xorg'] && is_null($this->xorg_infos
['forlife'])) {
21 foreach ($this->xorg_infos
as $key => $val) {
22 $this->xorg_infos
[$key] = $_SESSION['auth-xorg-' . $key];
27 public function checkUser($user_id, $pwd = null
, $user_key = null
) {
28 return $this->callXorg();
29 // echo "checking auth for " . $user_id;
30 return parent
::checkUser($user_id, $pwd, $user_key);
33 public function check($permissions, $blog_id) {
34 $this->buildFromSession();
35 // echo "Checking right to view $permissions on $blog_id";
36 return parent
::check($permissions, $blog_id);
39 public function callXorg($path = null
) {
41 $path = $_SERVER['REQUEST_URI'];
43 $this->buildFromSession();
44 if (@$_SESSION['auth-xorg']) {
47 $_SESSION["auth-x-challenge"] = md5(uniqid(rand(), 1));
48 $url = "https://www.polytechnique.org/auth-groupex/utf8";
49 $url .= "?session=" . session_id();
50 $url .= "&challenge=" . $_SESSION["auth-x-challenge"];
51 $url .= "&pass=" . md5($_SESSION["auth-x-challenge"] . XORG_AUTH_KEY
);
52 $url .= "&url=http://murphy.m4x.org/~x2003bruneau/dotclear/auth/XorgReturn" . urlencode("?path=" . $path);
53 session_write_close();
54 header("Location: $url");
58 public function returnXorg() {
59 if (!isset($_GET['auth'])) {
64 $core->session
->start();
65 foreach($this->xorg_infos
as $key => $val) {
66 if(!isset($_GET[$key])) {
69 $_SESSION['auth-xorg-' . $key] = $_GET[$key];
70 $params .= $_GET[$key];
72 if (md5('1' . $_SESSION['auth-x-challenge'] . XORG_AUTH_KEY
. $params . '1') == $_GET['auth']) {
74 $_SESSION['auth-xorg'] = $_GET['forlife'];
75 header("Location: http://murphy.m4x.org" . $_GET['path']);
78 $_SESSION['auth-xorg'] = null
;
84 public function killSession() {
86 $core->session
->start();
87 $core->session
->destroy();
88 header('Location: http://murphy.m4x.org/~x2003bruneau/dotclear/');