1
|
|
|
<?php defined('BASEPATH') OR exit('No direct script access allowed'); |
2
|
|
|
|
3
|
|
|
class My_Public extends CI_Controller { |
4
|
|
|
|
5
|
|
|
function __construct() { |
|
|
|
|
6
|
|
|
parent::__construct(); |
7
|
|
|
$this->load->model('user_model'); |
8
|
|
|
|
9
|
|
|
if (isset($_COOKIE['CI-CONCRETE5']) === TRUE) { |
10
|
|
|
|
11
|
|
|
$cookie = $_COOKIE['CI-CONCRETE5']; |
12
|
|
|
$key = $this->config->item('concrete5authkey'); |
13
|
|
|
$username = $this->user_model->decrypt($key, $cookie); |
14
|
|
|
|
15
|
|
|
if ($this->user_model->user_exist($username) === FALSE) { |
16
|
|
|
|
17
|
|
|
//expire fake cookie |
18
|
|
|
setcookie('CI-CONCRETE5', 'expired', time() - (1), "/"); |
19
|
|
|
} else { |
20
|
|
|
|
21
|
|
|
$user_ldap = $this->user_model->user_ldap($username); |
22
|
|
|
|
23
|
|
|
if ($user_ldap['useraccountcontrol'] == '66050') { |
24
|
|
|
// disabled, password never expire |
25
|
|
|
redirect('http://'.$_SERVER['HTTP_HOST'].'/authentication/user-disabled'); |
26
|
|
|
} elseif ($user_ldap['useraccountcontrol'] == '514') { |
27
|
|
|
// disabled |
28
|
|
|
redirect('/authentication/user-disabled'); |
29
|
|
|
} else { |
30
|
|
|
|
31
|
|
|
if (!in_array('CN=Staff,OU=Groups,DC=cant-col,DC=ac,DC=uk', $user_ldap['groups'])) { |
32
|
|
|
|
33
|
|
|
redirect('http://'.$_SERVER['HTTP_HOST'].'/authentication/user-disabled'); |
34
|
|
|
} else { |
35
|
|
|
|
36
|
|
|
$ip = $_SERVER['REMOTE_ADDR']; |
37
|
|
|
$is_private = $this->user_model->ip_is_private($ip); |
38
|
|
|
$uid = $this->user_model->get_uid_from_username($username); |
39
|
|
|
$this->user_model->set_user($uid, $username, $ip); |
40
|
|
|
|
41
|
|
|
$this->session->set_userdata('username', $username); |
42
|
|
|
$this->session->set_userdata('uid', $uid); |
43
|
|
|
$this->session->set_userdata('ldap', $user_ldap); |
44
|
|
|
$this->session->set_userdata('is_private', $is_private); |
45
|
|
|
|
46
|
|
|
//uses sessions |
47
|
|
|
$this->user_model->user_log(); |
48
|
|
|
|
49
|
|
|
if ($is_private === TRUE) { |
50
|
|
|
|
51
|
|
|
// reset as internal |
52
|
|
|
$this->user_model->external_login_reset($uid); |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
class My_Force_Login extends CI_Controller { |
63
|
|
|
|
64
|
|
|
function __construct() { |
|
|
|
|
65
|
|
|
parent::__construct(); |
66
|
|
|
|
67
|
|
|
if (isset($_COOKIE['CI-CONCRETE5']) === FALSE) { |
68
|
|
|
|
69
|
|
|
$this->session->set_userdata('last_url', current_url()); |
70
|
|
|
redirect('http://'.$_SERVER['HTTP_HOST'].'/authentication/dashboard?url=' . current_url()); |
71
|
|
|
} else { |
72
|
|
|
|
73
|
|
|
$cookie = $_COOKIE['CI-CONCRETE5']; |
74
|
|
|
$key = $this->config->item('concrete5authkey'); |
75
|
|
|
$username = $this->user_model->decrypt($key, $cookie); |
76
|
|
|
|
77
|
|
|
if ($this->user_model->user_exist($username) === FALSE) { |
78
|
|
|
|
79
|
|
|
//expire fake cookie |
80
|
|
|
setcookie('CI-CONCRETE5', 'expired', time() - (1), "/"); |
81
|
|
|
$this->session->set_userdata('last_url', current_url()); |
82
|
|
|
redirect('http://'.$_SERVER['HTTP_HOST'].'/authentication/dashboard?url=' . current_url()); |
83
|
|
|
} else { |
84
|
|
|
|
85
|
|
|
$user_ldap = $this->user_model->user_ldap($username); |
86
|
|
|
|
87
|
|
|
if ($user_ldap['useraccountcontrol'] == '66050') { |
88
|
|
|
// disabled, password never expire |
89
|
|
|
redirect('http://'.$_SERVER['HTTP_HOST'].'/authentication/user-disabled'); |
90
|
|
|
} elseif ($user_ldap['useraccountcontrol'] == '514') { |
91
|
|
|
// disabled |
92
|
|
|
redirect('http://'.$_SERVER['HTTP_HOST'].'/authentication/user-disabled'); |
93
|
|
|
} else { |
94
|
|
|
|
95
|
|
|
if (!in_array('CN=Staff,OU=Groups,DC=cant-col,DC=ac,DC=uk', $user_ldap['groups'])) { |
96
|
|
|
|
97
|
|
|
redirect('http://'.$_SERVER['HTTP_HOST'].'/authentication/user-disabled'); |
98
|
|
|
} else { |
99
|
|
|
|
100
|
|
|
$ip = $_SERVER['REMOTE_ADDR']; |
101
|
|
|
$is_private = $this->user_model->ip_is_private($ip); |
102
|
|
|
if ($is_private === FALSE) { |
103
|
|
|
|
104
|
|
|
if (isset($_SESSION['external_login']) === FALSE) { |
105
|
|
|
|
106
|
|
|
$this->session->set_userdata('last_url', current_url()); |
107
|
|
|
redirect('http://'.$_SERVER['HTTP_HOST'].'/dashboard/authentication/external-login'); |
108
|
|
View Code Duplication |
} else { |
|
|
|
|
109
|
|
|
|
110
|
|
|
$uid = $this->user_model->get_uid_from_username($username); |
111
|
|
|
$this->user_model->set_user($uid, $username, $ip); |
112
|
|
|
$this->user_model->external_login_reset($uid); |
113
|
|
|
// reset as internal |
114
|
|
|
|
115
|
|
|
$this->session->set_userdata('username', $username); |
116
|
|
|
$this->session->set_userdata('uid', $uid); |
117
|
|
|
$this->session->set_userdata('ldap', $user_ldap); |
118
|
|
|
$this->session->set_userdata('is_private', $is_private); |
119
|
|
|
|
120
|
|
|
//uses sessions |
121
|
|
|
$this->user_model->user_log(); |
122
|
|
|
} |
123
|
|
View Code Duplication |
} else { |
|
|
|
|
124
|
|
|
|
125
|
|
|
$uid = $this->user_model->get_uid_from_username($username); |
126
|
|
|
$this->user_model->set_user($uid, $username, $ip); |
127
|
|
|
$this->user_model->external_login_reset($uid); |
128
|
|
|
// reset as internal |
129
|
|
|
|
130
|
|
|
$this->session->set_userdata('username', $username); |
131
|
|
|
$this->session->set_userdata('uid', $uid); |
132
|
|
|
$this->session->set_userdata('ldap', $user_ldap); |
133
|
|
|
$this->session->set_userdata('is_private', $is_private); |
134
|
|
|
|
135
|
|
|
//uses sessions |
136
|
|
|
$this->user_model->user_log(); |
137
|
|
|
} |
138
|
|
|
} |
139
|
|
|
} |
140
|
|
|
} |
141
|
|
|
} |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
class My_Force_Login_Internal extends My_Force_Login { |
147
|
|
|
|
148
|
|
|
function __construct() { |
|
|
|
|
149
|
|
|
parent::__construct(); |
150
|
|
|
|
151
|
|
|
$ip = $_SERVER['REMOTE_ADDR']; |
152
|
|
|
$is_private = $this->user_model->ip_is_private($ip); |
153
|
|
|
if ($is_private === FALSE || !in_array('CN=Dashboard_Admin,OU=Dashboard_Group,OU=Intranet_Group,OU=Groups,DC=cant-col,DC=ac,DC=uk', $_SESSION['ldap']['groups'])) { |
154
|
|
|
|
155
|
|
|
redirect('/dashboard/authentication/internal'); |
156
|
|
|
} |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
class My_Force_Admin extends My_Force_Login { |
162
|
|
|
|
163
|
|
|
function __construct() { |
|
|
|
|
164
|
|
|
parent::__construct(); |
165
|
|
|
|
166
|
|
|
if (!in_array('CN=Dashboard_Admin,OU=Dashboard_Group,OU=Intranet_Group,OU=Groups,DC=cant-col,DC=ac,DC=uk', $_SESSION['ldap']['groups'])) { |
167
|
|
|
|
168
|
|
|
$this->load->view('templates/error/permissions'); |
169
|
|
|
} |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
} |
173
|
|
|
|
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.