-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathauth.php
More file actions
116 lines (97 loc) · 2.88 KB
/
auth.php
File metadata and controls
116 lines (97 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?php
/*
* This file is part of evQueue
*
* evQueue 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 3 of the License, or
* (at your option) any later version.
*
* evQueue 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 evQueue. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Nicolas Jean, Christophe Marti
*/
require_once __DIR__ . '/includes/inc/logger.php';
require_once __DIR__ . '/includes/lib/XSLEngine.php';
require_once __DIR__ . '/includes/inc/evqueue.php';
if(count($QUEUEING) == 0)
{
// Not yet configured
header('Location: install.php');
die();
}
if (isset($_GET['action']) && $_GET['action']=='logout')
{
@session_start();
$sessionName = session_name();
$sessionCookie = session_get_cookie_params();
session_destroy();
setcookie($sessionName, false, $sessionCookie['lifetime'], $sessionCookie['path'], $sessionCookie['domain'], $sessionCookie['secure']);
header('Location: auth.php');
die();
}
// Redirect to index if already identified
if(isset($_SESSION['user_login']))
{
header('Location: index.php');
die();
}
$xsl = new XSLEngine();
// Try anonymous login
try{
$cluster->Api('ping');
$_SESSION['user_login'] = "anonymous";
$_SESSION['user_pwd'] = "";
$_SESSION['user_profile'] = "ADMIN";
$node_names = $cluster->GetNodeNames();
$_SESSION['nodes'] = $node_names;
$query = parse_url($_SERVER['REQUEST_URI'],PHP_URL_QUERY);
header('Location: index.php'.(empty($query)?'':'?'.$query));
die();
}
catch(Exception $e){
if($e->getCode() != evQueue::ERROR_AUTH_REQUIRED){
$xsl->AddError($e->getMessage());
$xsl->DisplayXHTML('xsl/auth.xsl');
die();
}
}
if (isset($_POST['login']) && isset($_POST['password'])) {
$pwd = sha1($_POST['password'], true);
$cluster->SetUserLoginPwd($_POST['login'], $pwd, true);
try
{
$xsl->Api('ping');
}
catch(Exception $e)
{
$xsl->DisplayXHTML('xsl/auth.xsl');
die();
}
try {
$node_names = $cluster->GetNodeNames();
}
catch (Exception $e) {
$xsl->DisplayXHTML('xsl/auth.xsl');
die();
}
@session_start();
$_SESSION = [];
$_SESSION['user_login'] = $_POST['login'];
$_SESSION['user_pwd'] = $pwd;
$_SESSION['user_profile'] = $cluster->GetProfile();
$_SESSION['nodes'] = $node_names;
$_SESSION['git_enabled'] = $cluster->GetConfigurationEntry('git.repository')!=""?true:false;
session_write_close();
$query = parse_url($_SERVER['REQUEST_URI'],PHP_URL_QUERY);
header('Location: index.php'.(empty($query)?'':'?'.$query));
die();
}
$xsl->DisplayXHTML('xsl/auth.xsl');
?>