|
@@ -44,14 +44,14 @@ discard block |
|
|
block discarded – undo |
|
44
|
44
|
throw new Exception("Error file '/includes/config/tp.config.php' not exists", 1); |
|
45
|
45
|
} |
|
46
|
46
|
|
|
47
|
|
-if (! isset($SETTINGS['cpassman_dir']) || empty($SETTINGS['cpassman_dir']) === true || $SETTINGS['cpassman_dir'] === '.') { |
|
|
47
|
+if (!isset($SETTINGS['cpassman_dir']) || empty($SETTINGS['cpassman_dir']) === true || $SETTINGS['cpassman_dir'] === '.') { |
|
48
|
48
|
$SETTINGS = []; |
|
49
|
49
|
$SETTINGS['cpassman_dir'] = '..'; |
|
50
|
50
|
} |
|
51
|
51
|
|
|
52
|
|
-require_once $SETTINGS['cpassman_dir'] . '/sources/main.functions.php'; |
|
53
|
|
-require_once $SETTINGS['cpassman_dir'] . '/includes/config/include.php'; |
|
54
|
|
-require_once $SETTINGS['cpassman_dir'] . '/includes/config/settings.php'; |
|
|
52
|
+require_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php'; |
|
|
53
|
+require_once $SETTINGS['cpassman_dir'].'/includes/config/include.php'; |
|
|
54
|
+require_once $SETTINGS['cpassman_dir'].'/includes/config/settings.php'; |
|
55
|
55
|
|
|
56
|
56
|
// Prepare POST variables |
|
57
|
57
|
$post_type = filter_input(INPUT_POST, 'type', FILTER_SANITIZE_STRING); |
|
@@ -63,7 +63,7 @@ discard block |
|
|
block discarded – undo |
|
63
|
63
|
if (defined('DB_PASSWD_CLEAR') === false) { |
|
64
|
64
|
define('DB_PASSWD_CLEAR', defuseReturnDecrypted(DB_PASSWD, $SETTINGS)); |
|
65
|
65
|
} |
|
66
|
|
-require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Database/Meekrodb/db.class.php'; |
|
|
66
|
+require_once $SETTINGS['cpassman_dir'].'/includes/libraries/Database/Meekrodb/db.class.php'; |
|
67
|
67
|
if (defined('DB_PASSWD_CLEAR') === false) { |
|
68
|
68
|
define('DB_PASSWD_CLEAR', defuseReturnDecrypted(DB_PASSWD, $SETTINGS)); |
|
69
|
69
|
} |
|
@@ -85,12 +85,12 @@ discard block |
|
|
block discarded – undo |
|
85
|
85
|
defineComplexity(); |
|
86
|
86
|
|
|
87
|
87
|
// Load superGlobals |
|
88
|
|
- include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/protect/SuperGlobal/SuperGlobal.php'; |
|
|
88
|
+ include_once $SETTINGS['cpassman_dir'].'/includes/libraries/protect/SuperGlobal/SuperGlobal.php'; |
|
89
|
89
|
$superGlobal = new protect\SuperGlobal\SuperGlobal(); |
|
90
|
90
|
|
|
91
|
91
|
// If Debug then clean the files |
|
92
|
92
|
if (DEBUGLDAP === true) { |
|
93
|
|
- define('DEBUGLDAPFILE', $SETTINGS['path_to_files_folder'] . '/ldap.debug.txt'); |
|
|
93
|
+ define('DEBUGLDAPFILE', $SETTINGS['path_to_files_folder'].'/ldap.debug.txt'); |
|
94
|
94
|
file_put_contents(DEBUGLDAPFILE, ''); |
|
95
|
95
|
} |
|
96
|
96
|
|
|
@@ -174,19 +174,19 @@ discard block |
|
|
block discarded – undo |
|
174
|
174
|
if (findTpConfigFile() === false) { |
|
175
|
175
|
throw new Exception("Error file '/includes/config/tp.config.php' not exists", 1); |
|
176
|
176
|
} |
|
177
|
|
- include_once $SETTINGS['cpassman_dir'] . '/includes/config/settings.php'; |
|
178
|
|
- include_once $SETTINGS['cpassman_dir'] . '/sources/main.functions.php'; |
|
179
|
|
- include_once $SETTINGS['cpassman_dir'] . '/sources/SplClassLoader.php'; |
|
|
177
|
+ include_once $SETTINGS['cpassman_dir'].'/includes/config/settings.php'; |
|
|
178
|
+ include_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php'; |
|
|
179
|
+ include_once $SETTINGS['cpassman_dir'].'/sources/SplClassLoader.php'; |
|
180
|
180
|
|
|
181
|
181
|
header('Content-type: text/html; charset=utf-8'); |
|
182
|
182
|
error_reporting(E_ERROR); |
|
183
|
183
|
|
|
184
|
184
|
// Load AntiXSS |
|
185
|
|
- include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/voku/helper/AntiXSS.php'; |
|
|
185
|
+ include_once $SETTINGS['cpassman_dir'].'/includes/libraries/voku/helper/AntiXSS.php'; |
|
186
|
186
|
$antiXss = new voku\helper\AntiXSS(); |
|
187
|
187
|
|
|
188
|
188
|
// Load superGlobals |
|
189
|
|
- include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/protect/SuperGlobal/SuperGlobal.php'; |
|
|
189
|
+ include_once $SETTINGS['cpassman_dir'].'/includes/libraries/protect/SuperGlobal/SuperGlobal.php'; |
|
190
|
190
|
$superGlobal = new protect\SuperGlobal\SuperGlobal(); |
|
191
|
191
|
|
|
192
|
192
|
// Prepare GET variables |
|
@@ -200,7 +200,7 @@ discard block |
|
|
block discarded – undo |
|
200
|
200
|
$server['PHP_AUTH_PW'] = $superGlobal->get('PHP_AUTH_PW', 'SERVER'); |
|
201
|
201
|
|
|
202
|
202
|
// connect to the server |
|
203
|
|
- include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Database/Meekrodb/db.class.php'; |
|
|
203
|
+ include_once $SETTINGS['cpassman_dir'].'/includes/libraries/Database/Meekrodb/db.class.php'; |
|
204
|
204
|
DB::$host = DB_HOST; |
|
205
|
205
|
DB::$user = DB_USER; |
|
206
|
206
|
DB::$password = defined('DB_PASSWD_CLEAR') === false ? defuseReturnDecrypted(DB_PASSWD, $SETTINGS) : DB_PASSWD_CLEAR; |
|
@@ -210,7 +210,7 @@ discard block |
|
|
block discarded – undo |
|
210
|
210
|
DB::$ssl = DB_SSL; |
|
211
|
211
|
DB::$connect_options = DB_CONNECT_OPTIONS; |
|
212
|
212
|
// User's language loading |
|
213
|
|
- include_once $SETTINGS['cpassman_dir'] . '/includes/language/' . $sessionUserLanguage . '.php'; |
|
|
213
|
+ include_once $SETTINGS['cpassman_dir'].'/includes/language/'.$sessionUserLanguage.'.php'; |
|
214
|
214
|
|
|
215
|
215
|
// decrypt and retreive data in JSON format |
|
216
|
216
|
if (empty($sessionKey) === true) { |
|
@@ -226,18 +226,18 @@ discard block |
|
|
block discarded – undo |
|
226
|
226
|
} |
|
227
|
227
|
|
|
228
|
228
|
// Check if Duo auth is in progress and pass the pw and login back to the standard login process |
|
229
|
|
- if( |
|
|
229
|
+ if ( |
|
230
|
230
|
isKeyExistingAndEqual('duo', 1, $SETTINGS) === true |
|
231
|
231
|
&& $dataReceived['user_2fa_selection'] === 'duo' |
|
232
|
|
- && $superGlobal->get('duo_status','SESSION') === 'IN_PROGRESS' |
|
|
232
|
+ && $superGlobal->get('duo_status', 'SESSION') === 'IN_PROGRESS' |
|
233
|
233
|
&& !empty($dataReceived['duo_state']) |
|
234
|
|
- ){ |
|
|
234
|
+ ) { |
|
235
|
235
|
$key = hash('sha256', $dataReceived['duo_state']); |
|
236
|
236
|
$iv = substr(hash('sha256', $dataReceived['duo_state']), 0, 16); |
|
237
|
|
- $duo_data_dec = openssl_decrypt(base64_decode($superGlobal->get('duo_data','SESSION')), 'AES-256-CBC', $key, 0, $iv); |
|
|
237
|
+ $duo_data_dec = openssl_decrypt(base64_decode($superGlobal->get('duo_data', 'SESSION')), 'AES-256-CBC', $key, 0, $iv); |
|
238
|
238
|
// Clear the data from the Duo process to continue clean with the standard login process |
|
239
|
|
- $superGlobal->forget('duo_data','SESSION'); |
|
240
|
|
- if($duo_data_dec === false){ |
|
|
239
|
+ $superGlobal->forget('duo_data', 'SESSION'); |
|
|
240
|
+ if ($duo_data_dec === false) { |
|
241
|
241
|
echo prepareExchangedData( |
|
242
|
242
|
$SETTINGS['cpassman_dir'], |
|
243
|
243
|
[ |
|
@@ -511,7 +511,7 @@ discard block |
|
|
block discarded – undo |
|
511
|
511
|
if (count($superGlobal->get('user_roles', 'SESSION')) > 0) { |
|
512
|
512
|
$rolesList = DB::query( |
|
513
|
513
|
'SELECT id, title, complexity |
|
514
|
|
- FROM ' . prefixTable('roles_title') . ' |
|
|
514
|
+ FROM ' . prefixTable('roles_title').' |
|
515
|
515
|
WHERE id IN %li', |
|
516
|
516
|
$superGlobal->get('user_roles', 'SESSION') |
|
517
|
517
|
); |
|
@@ -534,7 +534,7 @@ discard block |
|
|
block discarded – undo |
|
534
|
534
|
|
|
535
|
535
|
// build complete array of roles |
|
536
|
536
|
$superGlobal->put('arr_roles_full', [], 'SESSION'); |
|
537
|
|
- $rows = DB::query('SELECT id, title FROM ' . prefixTable('roles_title') . ' ORDER BY title ASC'); |
|
|
537
|
+ $rows = DB::query('SELECT id, title FROM '.prefixTable('roles_title').' ORDER BY title ASC'); |
|
538
|
538
|
foreach ($rows as $record) { |
|
539
|
539
|
$superGlobal->put( |
|
540
|
540
|
$record['id'], |
|
@@ -606,10 +606,10 @@ discard block |
|
|
block discarded – undo |
|
606
|
606
|
$superGlobal->put('latest_items_tab', [], 'SESSION'); |
|
607
|
607
|
$superGlobal->put('nb_roles', 0, 'SESSION'); |
|
608
|
608
|
foreach ($superGlobal->get('latest_items', 'SESSION') as $item) { |
|
609
|
|
- if (! empty($item)) { |
|
|
609
|
+ if (!empty($item)) { |
|
610
|
610
|
$dataLastItems = DB::queryFirstRow( |
|
611
|
611
|
'SELECT id,label,id_tree |
|
612
|
|
- FROM ' . prefixTable('items') . ' |
|
|
612
|
+ FROM ' . prefixTable('items').' |
|
613
|
613
|
WHERE id=%i', |
|
614
|
614
|
$item |
|
615
|
615
|
); |
|
@@ -618,7 +618,7 @@ discard block |
|
|
block discarded – undo |
|
618
|
618
|
[ |
|
619
|
619
|
'id' => $item, |
|
620
|
620
|
'label' => $dataLastItems['label'], |
|
621
|
|
- 'url' => 'index.php?page=items&group=' . $dataLastItems['id_tree'] . '&id=' . $item, |
|
|
621
|
+ 'url' => 'index.php?page=items&group='.$dataLastItems['id_tree'].'&id='.$item, |
|
622
|
622
|
], |
|
623
|
623
|
'SESSION', |
|
624
|
624
|
'latest_items_tab' |
|
@@ -634,12 +634,12 @@ discard block |
|
|
block discarded – undo |
|
634
|
634
|
) { |
|
635
|
635
|
// get all Admin users |
|
636
|
636
|
$receivers = ''; |
|
637
|
|
- $rows = DB::query('SELECT email FROM ' . prefixTable('users') . " WHERE admin = %i and email != ''", 1); |
|
|
637
|
+ $rows = DB::query('SELECT email FROM '.prefixTable('users')." WHERE admin = %i and email != ''", 1); |
|
638
|
638
|
foreach ($rows as $record) { |
|
639
|
639
|
if (empty($receivers)) { |
|
640
|
640
|
$receivers = $record['email']; |
|
641
|
641
|
} else { |
|
642
|
|
- $receivers = ',' . $record['email']; |
|
|
642
|
+ $receivers = ','.$record['email']; |
|
643
|
643
|
} |
|
644
|
644
|
} |
|
645
|
645
|
// Add email to table |
|
@@ -655,7 +655,7 @@ discard block |
|
|
block discarded – undo |
|
655
|
655
|
'#tp_time#', |
|
656
|
656
|
], |
|
657
|
657
|
[ |
|
658
|
|
- ' ' . $superGlobal->get('login', 'SESSION') . ' (IP: ' . getClientIpServer() . ')', |
|
|
658
|
+ ' '.$superGlobal->get('login', 'SESSION').' (IP: '.getClientIpServer().')', |
|
659
|
659
|
date($SETTINGS['date_format'], (int) $superGlobal->get('last_connection', 'SESSION')), |
|
660
|
660
|
date($SETTINGS['time_format'], (int) $superGlobal->get('last_connection', 'SESSION')), |
|
661
|
661
|
], |
|
@@ -809,7 +809,7 @@ discard block |
|
|
block discarded – undo |
|
809
|
809
|
{ |
|
810
|
810
|
$rows = DB::query( |
|
811
|
811
|
'SELECT date |
|
812
|
|
- FROM ' . prefixTable('log_system') . " |
|
|
812
|
+ FROM ' . prefixTable('log_system')." |
|
813
|
813
|
WHERE field_1 = %s |
|
814
|
814
|
AND type = 'failed_auth' |
|
815
|
815
|
AND label = 'password_is_not_correct' |
|
@@ -823,7 +823,7 @@ discard block |
|
|
block discarded – undo |
|
823
|
823
|
foreach ($rows as $record) { |
|
824
|
824
|
array_push( |
|
825
|
825
|
$arrAttempts, |
|
826
|
|
- date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['date']) |
|
|
826
|
+ date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['date']) |
|
827
|
827
|
); |
|
828
|
828
|
} |
|
829
|
829
|
} |
|
@@ -877,7 +877,7 @@ discard block |
|
|
block discarded – undo |
|
877
|
877
|
$ldapConnection |
|
878
|
878
|
) : bool |
|
879
|
879
|
{ |
|
880
|
|
- include_once $SETTINGS['cpassman_dir'] . '/sources/main.functions.php'; |
|
|
880
|
+ include_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php'; |
|
881
|
881
|
|
|
882
|
882
|
if ((int) $userInfoDisabled === 1) { |
|
883
|
883
|
return false; |
|
@@ -1080,44 +1080,44 @@ discard block |
|
|
block discarded – undo |
|
1080
|
1080
|
function authenticateThroughAD(string $username, array $userInfo, string $passwordClear, array $SETTINGS): array |
|
1081
|
1081
|
{ |
|
1082
|
1082
|
// Load expected libraries |
|
1083
|
|
- require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Illuminate/Contracts/Auth/Authenticatable.php'; |
|
1084
|
|
- require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Tightenco/Collect/Support/Traits/EnumeratesValues.php'; |
|
1085
|
|
- require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Tightenco/Collect/Support/Traits/Macroable.php'; |
|
1086
|
|
- require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Tightenco/Collect/Support/helpers.php'; |
|
1087
|
|
- require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Tightenco/Collect/Support/Arr.php'; |
|
1088
|
|
- require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Tightenco/Collect/Contracts/Support/Jsonable.php'; |
|
1089
|
|
- require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Tightenco/Collect/Contracts/Support/Arrayable.php'; |
|
1090
|
|
- require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Tightenco/Collect/Support/Enumerable.php'; |
|
1091
|
|
- require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Tightenco/Collect/Support/Collection.php'; |
|
1092
|
|
- require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Carbon/CarbonTimeZone.php'; |
|
1093
|
|
- require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Carbon/Traits/Units.php'; |
|
1094
|
|
- require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Carbon/Traits/Week.php'; |
|
1095
|
|
- require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Carbon/Traits/Timestamp.php'; |
|
1096
|
|
- require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Carbon/Traits/Test.php'; |
|
1097
|
|
- require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Carbon/Traits/ObjectInitialisation.php'; |
|
1098
|
|
- require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Carbon/Traits/Serialization.php'; |
|
1099
|
|
- require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Carbon/Traits/IntervalRounding.php'; |
|
1100
|
|
- require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Carbon/Traits/Rounding.php'; |
|
1101
|
|
- require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Carbon/Traits/Localization.php'; |
|
1102
|
|
- require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Carbon/Traits/Options.php'; |
|
1103
|
|
- require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Carbon/Traits/Cast.php'; |
|
1104
|
|
- require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Carbon/Traits/Mutability.php'; |
|
1105
|
|
- require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Carbon/Traits/Modifiers.php'; |
|
1106
|
|
- require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Carbon/Traits/Mixin.php'; |
|
1107
|
|
- require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Carbon/Traits/Macro.php'; |
|
1108
|
|
- require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Carbon/Traits/Difference.php'; |
|
1109
|
|
- require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Carbon/Traits/Creator.php'; |
|
1110
|
|
- require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Carbon/Traits/Converter.php'; |
|
1111
|
|
- require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Carbon/Traits/Comparison.php'; |
|
1112
|
|
- require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Carbon/Traits/Boundaries.php'; |
|
1113
|
|
- require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Carbon/Traits/Date.php'; |
|
1114
|
|
- require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Carbon/CarbonInterface.php'; |
|
1115
|
|
- require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Carbon/Carbon.php'; |
|
1116
|
|
- require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/LdapRecord/DetectsErrors.php'; |
|
1117
|
|
- require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/LdapRecord/Connection.php'; |
|
1118
|
|
- require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/LdapRecord/LdapInterface.php'; |
|
1119
|
|
- require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/LdapRecord/HandlesConnection.php'; |
|
1120
|
|
- require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/LdapRecord/Ldap.php'; |
|
|
1083
|
+ require_once $SETTINGS['cpassman_dir'].'/includes/libraries/Illuminate/Contracts/Auth/Authenticatable.php'; |
|
|
1084
|
+ require_once $SETTINGS['cpassman_dir'].'/includes/libraries/Tightenco/Collect/Support/Traits/EnumeratesValues.php'; |
|
|
1085
|
+ require_once $SETTINGS['cpassman_dir'].'/includes/libraries/Tightenco/Collect/Support/Traits/Macroable.php'; |
|
|
1086
|
+ require_once $SETTINGS['cpassman_dir'].'/includes/libraries/Tightenco/Collect/Support/helpers.php'; |
|
|
1087
|
+ require_once $SETTINGS['cpassman_dir'].'/includes/libraries/Tightenco/Collect/Support/Arr.php'; |
|
|
1088
|
+ require_once $SETTINGS['cpassman_dir'].'/includes/libraries/Tightenco/Collect/Contracts/Support/Jsonable.php'; |
|
|
1089
|
+ require_once $SETTINGS['cpassman_dir'].'/includes/libraries/Tightenco/Collect/Contracts/Support/Arrayable.php'; |
|
|
1090
|
+ require_once $SETTINGS['cpassman_dir'].'/includes/libraries/Tightenco/Collect/Support/Enumerable.php'; |
|
|
1091
|
+ require_once $SETTINGS['cpassman_dir'].'/includes/libraries/Tightenco/Collect/Support/Collection.php'; |
|
|
1092
|
+ require_once $SETTINGS['cpassman_dir'].'/includes/libraries/Carbon/CarbonTimeZone.php'; |
|
|
1093
|
+ require_once $SETTINGS['cpassman_dir'].'/includes/libraries/Carbon/Traits/Units.php'; |
|
|
1094
|
+ require_once $SETTINGS['cpassman_dir'].'/includes/libraries/Carbon/Traits/Week.php'; |
|
|
1095
|
+ require_once $SETTINGS['cpassman_dir'].'/includes/libraries/Carbon/Traits/Timestamp.php'; |
|
|
1096
|
+ require_once $SETTINGS['cpassman_dir'].'/includes/libraries/Carbon/Traits/Test.php'; |
|
|
1097
|
+ require_once $SETTINGS['cpassman_dir'].'/includes/libraries/Carbon/Traits/ObjectInitialisation.php'; |
|
|
1098
|
+ require_once $SETTINGS['cpassman_dir'].'/includes/libraries/Carbon/Traits/Serialization.php'; |
|
|
1099
|
+ require_once $SETTINGS['cpassman_dir'].'/includes/libraries/Carbon/Traits/IntervalRounding.php'; |
|
|
1100
|
+ require_once $SETTINGS['cpassman_dir'].'/includes/libraries/Carbon/Traits/Rounding.php'; |
|
|
1101
|
+ require_once $SETTINGS['cpassman_dir'].'/includes/libraries/Carbon/Traits/Localization.php'; |
|
|
1102
|
+ require_once $SETTINGS['cpassman_dir'].'/includes/libraries/Carbon/Traits/Options.php'; |
|
|
1103
|
+ require_once $SETTINGS['cpassman_dir'].'/includes/libraries/Carbon/Traits/Cast.php'; |
|
|
1104
|
+ require_once $SETTINGS['cpassman_dir'].'/includes/libraries/Carbon/Traits/Mutability.php'; |
|
|
1105
|
+ require_once $SETTINGS['cpassman_dir'].'/includes/libraries/Carbon/Traits/Modifiers.php'; |
|
|
1106
|
+ require_once $SETTINGS['cpassman_dir'].'/includes/libraries/Carbon/Traits/Mixin.php'; |
|
|
1107
|
+ require_once $SETTINGS['cpassman_dir'].'/includes/libraries/Carbon/Traits/Macro.php'; |
|
|
1108
|
+ require_once $SETTINGS['cpassman_dir'].'/includes/libraries/Carbon/Traits/Difference.php'; |
|
|
1109
|
+ require_once $SETTINGS['cpassman_dir'].'/includes/libraries/Carbon/Traits/Creator.php'; |
|
|
1110
|
+ require_once $SETTINGS['cpassman_dir'].'/includes/libraries/Carbon/Traits/Converter.php'; |
|
|
1111
|
+ require_once $SETTINGS['cpassman_dir'].'/includes/libraries/Carbon/Traits/Comparison.php'; |
|
|
1112
|
+ require_once $SETTINGS['cpassman_dir'].'/includes/libraries/Carbon/Traits/Boundaries.php'; |
|
|
1113
|
+ require_once $SETTINGS['cpassman_dir'].'/includes/libraries/Carbon/Traits/Date.php'; |
|
|
1114
|
+ require_once $SETTINGS['cpassman_dir'].'/includes/libraries/Carbon/CarbonInterface.php'; |
|
|
1115
|
+ require_once $SETTINGS['cpassman_dir'].'/includes/libraries/Carbon/Carbon.php'; |
|
|
1116
|
+ require_once $SETTINGS['cpassman_dir'].'/includes/libraries/LdapRecord/DetectsErrors.php'; |
|
|
1117
|
+ require_once $SETTINGS['cpassman_dir'].'/includes/libraries/LdapRecord/Connection.php'; |
|
|
1118
|
+ require_once $SETTINGS['cpassman_dir'].'/includes/libraries/LdapRecord/LdapInterface.php'; |
|
|
1119
|
+ require_once $SETTINGS['cpassman_dir'].'/includes/libraries/LdapRecord/HandlesConnection.php'; |
|
|
1120
|
+ require_once $SETTINGS['cpassman_dir'].'/includes/libraries/LdapRecord/Ldap.php'; |
|
1121
|
1121
|
$ad = new SplClassLoader('LdapRecord', '../includes/libraries'); |
|
1122
|
1122
|
$ad->register(); |
|
1123
|
1123
|
|
|
@@ -1153,7 +1153,7 @@ discard block |
|
|
block discarded – undo |
|
1153
|
1153
|
// Get user info from AD |
|
1154
|
1154
|
// We want to isolate attribute ldap_user_attribute |
|
1155
|
1155
|
$userADInfos = $connection->query() |
|
1156
|
|
- ->where((isset($SETTINGS['ldap_user_attribute']) ===true && empty($SETTINGS['ldap_user_attribute']) === false) ? strtolower($SETTINGS['ldap_user_attribute']) : 'distinguishedname', '=', $username) |
|
|
1156
|
+ ->where((isset($SETTINGS['ldap_user_attribute']) === true && empty($SETTINGS['ldap_user_attribute']) === false) ? strtolower($SETTINGS['ldap_user_attribute']) : 'distinguishedname', '=', $username) |
|
1157
|
1157
|
->firstOrFail(); |
|
1158
|
1158
|
|
|
1159
|
1159
|
// Check shadowexpire attribute - if === 1 then user disabled |
|
@@ -1185,7 +1185,7 @@ discard block |
|
|
block discarded – undo |
|
1185
|
1185
|
$error = $e->getDetailedError(); |
|
1186
|
1186
|
return [ |
|
1187
|
1187
|
'error' => true, |
|
1188
|
|
- 'message' => langHdl('error').' : '.$error->getErrorCode().' - '.$error->getErrorMessage(). '<br>'.$error->getDiagnosticMessage(), |
|
|
1188
|
+ 'message' => langHdl('error').' : '.$error->getErrorCode().' - '.$error->getErrorMessage().'<br>'.$error->getDiagnosticMessage(), |
|
1189
|
1189
|
|
|
1190
|
1190
|
]; |
|
1191
|
1191
|
} |
|
@@ -1199,7 +1199,7 @@ discard block |
|
|
block discarded – undo |
|
1199
|
1199
|
} |
|
1200
|
1200
|
|
|
1201
|
1201
|
// load passwordLib library |
|
1202
|
|
- $pwdlib = new SplClassLoader('PasswordLib', $SETTINGS['cpassman_dir'] . '/includes/libraries'); |
|
|
1202
|
+ $pwdlib = new SplClassLoader('PasswordLib', $SETTINGS['cpassman_dir'].'/includes/libraries'); |
|
1203
|
1203
|
$pwdlib->register(); |
|
1204
|
1204
|
$pwdlib = new PasswordLib\PasswordLib(); |
|
1205
|
1205
|
$hashedPassword = $pwdlib->createPasswordHash($passwordClear); |
|
@@ -1258,7 +1258,7 @@ discard block |
|
|
block discarded – undo |
|
1258
|
1258
|
function yubicoMFACheck($dataReceived, string $userInfo, array $SETTINGS): array |
|
1259
|
1259
|
{ |
|
1260
|
1260
|
// Load superGlobals |
|
1261
|
|
- include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/protect/SuperGlobal/SuperGlobal.php'; |
|
|
1261
|
+ include_once $SETTINGS['cpassman_dir'].'/includes/libraries/protect/SuperGlobal/SuperGlobal.php'; |
|
1262
|
1262
|
$superGlobal = new protect\SuperGlobal\SuperGlobal(); |
|
1263
|
1263
|
$sessionAdmin = $superGlobal->get('user_admin', 'SESSION'); |
|
1264
|
1264
|
$sessionUrl = $superGlobal->get('initial_url', 'SESSION'); |
|
@@ -1297,7 +1297,7 @@ discard block |
|
|
block discarded – undo |
|
1297
|
1297
|
} |
|
1298
|
1298
|
|
|
1299
|
1299
|
// Now check yubico validity |
|
1300
|
|
- include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Authentication/Yubico/Yubico.php'; |
|
|
1300
|
+ include_once $SETTINGS['cpassman_dir'].'/includes/libraries/Authentication/Yubico/Yubico.php'; |
|
1301
|
1301
|
$yubi = new Auth_Yubico($yubico_user_id, $yubico_user_key); |
|
1302
|
1302
|
$auth = $yubi->verify($yubico_key); |
|
1303
|
1303
|
//, null, null, null, 60 |
|
@@ -1349,7 +1349,7 @@ discard block |
|
|
block discarded – undo |
|
1349
|
1349
|
'gestionnaire' => '0', |
|
1350
|
1350
|
'can_manage_all_users' => '0', |
|
1351
|
1351
|
'personal_folder' => $SETTINGS['enable_pf_feature'] === '1' ? '1' : '0', |
|
1352
|
|
- 'fonction_id' => (empty($retLDAP['user_info_from_ad'][0]['commonGroupsLdapVsTeampass']) === false ? $retLDAP['user_info_from_ad'][0]['commonGroupsLdapVsTeampass'] . ';' : '') . (isset($SETTINGS['ldap_new_user_role']) === true ? $SETTINGS['ldap_new_user_role'] : '0'), |
|
|
1352
|
+ 'fonction_id' => (empty($retLDAP['user_info_from_ad'][0]['commonGroupsLdapVsTeampass']) === false ? $retLDAP['user_info_from_ad'][0]['commonGroupsLdapVsTeampass'].';' : '').(isset($SETTINGS['ldap_new_user_role']) === true ? $SETTINGS['ldap_new_user_role'] : '0'), |
|
1353
|
1353
|
'groupes_interdits' => '', |
|
1354
|
1354
|
'groupes_visibles' => '', |
|
1355
|
1355
|
'last_pw_change' => (int) time(), |
|
@@ -1375,7 +1375,7 @@ discard block |
|
|
block discarded – undo |
|
1375
|
1375
|
] |
|
1376
|
1376
|
); |
|
1377
|
1377
|
// Rebuild tree |
|
1378
|
|
- $tree = new SplClassLoader('Tree\NestedTree', $SETTINGS['cpassman_dir'] . '/includes/libraries'); |
|
|
1378
|
+ $tree = new SplClassLoader('Tree\NestedTree', $SETTINGS['cpassman_dir'].'/includes/libraries'); |
|
1379
|
1379
|
$tree->register(); |
|
1380
|
1380
|
$tree = new Tree\NestedTree\NestedTree(prefixTable('nested_tree'), 'id', 'parent_id', 'title'); |
|
1381
|
1381
|
$tree->rebuild(); |
|
@@ -1406,13 +1406,13 @@ discard block |
|
|
block discarded – undo |
|
1406
|
1406
|
&& empty($dataReceived['GACode']) === false |
|
1407
|
1407
|
) { |
|
1408
|
1408
|
// Load superGlobals |
|
1409
|
|
- include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/protect/SuperGlobal/SuperGlobal.php'; |
|
|
1409
|
+ include_once $SETTINGS['cpassman_dir'].'/includes/libraries/protect/SuperGlobal/SuperGlobal.php'; |
|
1410
|
1410
|
$superGlobal = new protect\SuperGlobal\SuperGlobal(); |
|
1411
|
1411
|
$sessionAdmin = $superGlobal->get('user_admin', 'SESSION'); |
|
1412
|
1412
|
$sessionUrl = $superGlobal->get('initial_url', 'SESSION'); |
|
1413
|
1413
|
$sessionPwdAttempts = $superGlobal->get('pwd_attempts', 'SESSION'); |
|
1414
|
1414
|
// load library |
|
1415
|
|
- include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Authentication/TwoFactorAuth/TwoFactorAuth.php'; |
|
|
1415
|
+ include_once $SETTINGS['cpassman_dir'].'/includes/libraries/Authentication/TwoFactorAuth/TwoFactorAuth.php'; |
|
1416
|
1416
|
// create new instance |
|
1417
|
1417
|
$tfa = new Authentication\TwoFactorAuth\TwoFactorAuth($SETTINGS['ga_website_name']); |
|
1418
|
1418
|
// Init |
|
@@ -1435,7 +1435,7 @@ discard block |
|
|
block discarded – undo |
|
1435
|
1435
|
$mfaMessage = langHdl('ga_flash_qr_and_login'); |
|
1436
|
1436
|
// generate new QR |
|
1437
|
1437
|
$new_2fa_qr = $tfa->getQRCodeImageAsDataUri( |
|
1438
|
|
- 'Teampass - ' . $username, |
|
|
1438
|
+ 'Teampass - '.$username, |
|
1439
|
1439
|
$userInfo['ga'] |
|
1440
|
1440
|
); |
|
1441
|
1441
|
// clear temporary code from DB |
|
@@ -1448,7 +1448,7 @@ discard block |
|
|
block discarded – undo |
|
1448
|
1448
|
$userInfo['id'] |
|
1449
|
1449
|
); |
|
1450
|
1450
|
$firstTime = [ |
|
1451
|
|
- 'value' => '<img src="' . $new_2fa_qr . '">', |
|
|
1451
|
+ 'value' => '<img src="'.$new_2fa_qr.'">', |
|
1452
|
1452
|
'user_admin' => isset($sessionAdmin) ? (int) $sessionAdmin : '', |
|
1453
|
1453
|
'initial_url' => isset($sessionUrl) === true ? $sessionUrl : '', |
|
1454
|
1454
|
'pwd_attempts' => (int) $sessionPwdAttempts, |
|
@@ -1510,7 +1510,7 @@ discard block |
|
|
block discarded – undo |
|
1510
|
1510
|
): array |
|
1511
|
1511
|
{ |
|
1512
|
1512
|
// Load superGlobals |
|
1513
|
|
- include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/protect/SuperGlobal/SuperGlobal.php'; |
|
|
1513
|
+ include_once $SETTINGS['cpassman_dir'].'/includes/libraries/protect/SuperGlobal/SuperGlobal.php'; |
|
1514
|
1514
|
$superGlobal = new protect\SuperGlobal\SuperGlobal(); |
|
1515
|
1515
|
|
|
1516
|
1516
|
// load libraries |
|
@@ -1556,7 +1556,7 @@ discard block |
|
|
block discarded – undo |
|
1556
|
1556
|
}*/ |
|
1557
|
1557
|
return [ |
|
1558
|
1558
|
'error' => true, |
|
1559
|
|
- 'message' => $duo_error . langHdl('duo_error_check_config'), |
|
|
1559
|
+ 'message' => $duo_error.langHdl('duo_error_check_config'), |
|
1560
|
1560
|
'pwd_attempts' => (int) $sessionPwdAttempts, |
|
1561
|
1561
|
'debug_message' => $e->getMessage(), |
|
1562
|
1562
|
'proceedIdentification' => false, |
|
@@ -1572,7 +1572,7 @@ discard block |
|
|
block discarded – undo |
|
1572
|
1572
|
} catch (Duo\DuoUniversal\DuoException $e) { |
|
1573
|
1573
|
return [ |
|
1574
|
1574
|
'error' => true, |
|
1575
|
|
- 'message' => $duo_error . langHdl('duo_error_url'), |
|
|
1575
|
+ 'message' => $duo_error.langHdl('duo_error_url'), |
|
1576
|
1576
|
'pwd_attempts' => (int) $sessionPwdAttempts, |
|
1577
|
1577
|
'debug_message' => $e->getMessage(), |
|
1578
|
1578
|
'proceedIdentification' => false, |
|
@@ -1580,7 +1580,7 @@ discard block |
|
|
block discarded – undo |
|
1580
|
1580
|
} |
|
1581
|
1581
|
|
|
1582
|
1582
|
// Somethimes Duo return success but fail to return a URL, double check if the URL has been created |
|
1583
|
|
- if (!empty($duo_redirect_url) && isset($duo_redirect_url) && filter_var($duo_redirect_url,FILTER_SANITIZE_URL)) { |
|
|
1583
|
+ if (!empty($duo_redirect_url) && isset($duo_redirect_url) && filter_var($duo_redirect_url, FILTER_SANITIZE_URL)) { |
|
1584
|
1584
|
// Since Duo Universal requires a redirect, let's store some info when the user get's back after completing the Duo prompt |
|
1585
|
1585
|
$key = hash('sha256', $duo_state); |
|
1586
|
1586
|
$iv = substr(hash('sha256', $duo_state), 0, 16); |
|
@@ -1606,7 +1606,7 @@ discard block |
|
|
block discarded – undo |
|
1606
|
1606
|
} else { |
|
1607
|
1607
|
return [ |
|
1608
|
1608
|
'error' => true, |
|
1609
|
|
- 'message' => $duo_error . langHdl('duo_error_url'), |
|
|
1609
|
+ 'message' => $duo_error.langHdl('duo_error_url'), |
|
1610
|
1610
|
'pwd_attempts' => (int) $sessionPwdAttempts, |
|
1611
|
1611
|
'proceedIdentification' => false, |
|
1612
|
1612
|
]; |
|
@@ -1627,8 +1627,8 @@ discard block |
|
|
block discarded – undo |
|
1627
|
1627
|
// return the response (which should be the user name) |
|
1628
|
1628
|
if ($decoded_token['preferred_username'] === $username) { |
|
1629
|
1629
|
$superGlobal->put('duo_status', 'COMPLET', 'SESSION'); |
|
1630
|
|
- $superGlobal->forget('duo_state','SESSION'); |
|
1631
|
|
- $superGlobal->forget('duo_data','SESSION'); |
|
|
1630
|
+ $superGlobal->forget('duo_state', 'SESSION'); |
|
|
1631
|
+ $superGlobal->forget('duo_data', 'SESSION'); |
|
1632
|
1632
|
unset($superGlobal); |
|
1633
|
1633
|
|
|
1634
|
1634
|
return [ |
|
@@ -1639,9 +1639,9 @@ discard block |
|
|
block discarded – undo |
|
1639
|
1639
|
]; |
|
1640
|
1640
|
} else { |
|
1641
|
1641
|
// Something wrong, username from the original Duo request is different than the one received now |
|
1642
|
|
- $superGlobal->forget('duo_status','SESSION'); |
|
1643
|
|
- $superGlobal->forget('duo_state','SESSION'); |
|
1644
|
|
- $superGlobal->forget('duo_data','SESSION'); |
|
|
1642
|
+ $superGlobal->forget('duo_status', 'SESSION'); |
|
|
1643
|
+ $superGlobal->forget('duo_state', 'SESSION'); |
|
|
1644
|
+ $superGlobal->forget('duo_data', 'SESSION'); |
|
1645
|
1645
|
unset($superGlobal); |
|
1646
|
1646
|
|
|
1647
|
1647
|
return [ |
|
@@ -1653,9 +1653,9 @@ discard block |
|
|
block discarded – undo |
|
1653
|
1653
|
} |
|
1654
|
1654
|
} |
|
1655
|
1655
|
// If we are here something wrong |
|
1656
|
|
- $superGlobal->forget('duo_status','SESSION'); |
|
1657
|
|
- $superGlobal->forget('duo_state','SESSION'); |
|
1658
|
|
- $superGlobal->forget('duo_data','SESSION'); |
|
|
1656
|
+ $superGlobal->forget('duo_status', 'SESSION'); |
|
|
1657
|
+ $superGlobal->forget('duo_state', 'SESSION'); |
|
|
1658
|
+ $superGlobal->forget('duo_data', 'SESSION'); |
|
1659
|
1659
|
unset($superGlobal); |
|
1660
|
1660
|
return [ |
|
1661
|
1661
|
'error' => true, |
|
@@ -1681,8 +1681,8 @@ discard block |
|
|
block discarded – undo |
|
1681
|
1681
|
// Set to false |
|
1682
|
1682
|
$userPasswordVerified = false; |
|
1683
|
1683
|
// load passwordLib library |
|
1684
|
|
- include_once $SETTINGS['cpassman_dir'] . '/sources/SplClassLoader.php'; |
|
1685
|
|
- $pwdlib = new SplClassLoader('PasswordLib', $SETTINGS['cpassman_dir'] . '/includes/libraries'); |
|
|
1684
|
+ include_once $SETTINGS['cpassman_dir'].'/sources/SplClassLoader.php'; |
|
|
1685
|
+ $pwdlib = new SplClassLoader('PasswordLib', $SETTINGS['cpassman_dir'].'/includes/libraries'); |
|
1686
|
1686
|
$pwdlib->register(); |
|
1687
|
1687
|
$pwdlib = new PasswordLib\PasswordLib(); |
|
1688
|
1688
|
// Check if old encryption used |
|
@@ -1822,7 +1822,7 @@ discard block |
|
|
block discarded – undo |
|
1822
|
1822
|
// Brute force management |
|
1823
|
1823
|
if ($sessionPwdAttempts > 3) { |
|
1824
|
1824
|
// Load superGlobals |
|
1825
|
|
- include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/protect/SuperGlobal/SuperGlobal.php'; |
|
|
1825
|
+ include_once $SETTINGS['cpassman_dir'].'/includes/libraries/protect/SuperGlobal/SuperGlobal.php'; |
|
1826
|
1826
|
$superGlobal = new protect\SuperGlobal\SuperGlobal(); |
|
1827
|
1827
|
$superGlobal->put('next_possible_pwd_attempts', time() + 10, 'SESSION'); |
|
1828
|
1828
|
$superGlobal->put('pwd_attempts', 0, 'SESSION'); |
|
@@ -1845,7 +1845,7 @@ discard block |
|
|
block discarded – undo |
|
1845
|
1845
|
// Check if user exists |
|
1846
|
1846
|
$userInfo = DB::queryFirstRow( |
|
1847
|
1847
|
'SELECT * |
|
1848
|
|
- FROM ' . prefixTable('users') . ' WHERE login=%s', |
|
|
1848
|
+ FROM ' . prefixTable('users').' WHERE login=%s', |
|
1849
|
1849
|
$username |
|
1850
|
1850
|
); |
|
1851
|
1851
|
|
|
@@ -2045,12 +2045,12 @@ discard block |
|
|
block discarded – undo |
|
2045
|
2045
|
case 'duo': |
|
2046
|
2046
|
// Prepare Duo connection if set up |
|
2047
|
2047
|
// Load superGlobals |
|
2048
|
|
- include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/protect/SuperGlobal/SuperGlobal.php'; |
|
|
2048
|
+ include_once $SETTINGS['cpassman_dir'].'/includes/libraries/protect/SuperGlobal/SuperGlobal.php'; |
|
2049
|
2049
|
$superGlobal = new protect\SuperGlobal\SuperGlobal(); |
|
2050
|
2050
|
|
|
2051
|
2051
|
$sessionPwdAttempts = $superGlobal->get('pwd_attempts', 'SESSION'); |
|
2052
|
|
- $saved_state = null !== $superGlobal->get('duo_state','SESSION') ? $superGlobal->get('duo_state','SESSION') : ''; |
|
2053
|
|
- $duo_status = null !== $superGlobal->get('duo_status','SESSION') ? $superGlobal->get('duo_status','SESSION') : ''; |
|
|
2052
|
+ $saved_state = null !== $superGlobal->get('duo_state', 'SESSION') ? $superGlobal->get('duo_state', 'SESSION') : ''; |
|
|
2053
|
+ $duo_status = null !== $superGlobal->get('duo_status', 'SESSION') ? $superGlobal->get('duo_status', 'SESSION') : ''; |
|
2054
|
2054
|
|
|
2055
|
2055
|
// Ensure state and login are set |
|
2056
|
2056
|
if ( |
|
@@ -2089,19 +2089,19 @@ discard block |
|
|
block discarded – undo |
|
2089
|
2089
|
if ($ret['error'] !== false) { |
|
2090
|
2090
|
logEvents($SETTINGS, 'failed_auth', 'bad_duo_mfa', '', stripslashes($username), stripslashes($username)); |
|
2091
|
2091
|
// Load superGlobals |
|
2092
|
|
- include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/protect/SuperGlobal/SuperGlobal.php'; |
|
|
2092
|
+ include_once $SETTINGS['cpassman_dir'].'/includes/libraries/protect/SuperGlobal/SuperGlobal.php'; |
|
2093
|
2093
|
# Retrieve the previously stored state and username from the session |
|
2094
|
2094
|
$superGlobal = new protect\SuperGlobal\SuperGlobal(); |
|
2095
|
|
- $superGlobal->forget('duo_state','SESSION'); |
|
2096
|
|
- $superGlobal->forget('duo_data','SESSION'); |
|
2097
|
|
- $superGlobal->forget('duo_status','SESSION'); |
|
|
2095
|
+ $superGlobal->forget('duo_state', 'SESSION'); |
|
|
2096
|
+ $superGlobal->forget('duo_data', 'SESSION'); |
|
|
2097
|
+ $superGlobal->forget('duo_status', 'SESSION'); |
|
2098
|
2098
|
unset($superGlobal); |
|
2099
|
2099
|
return [ |
|
2100
|
2100
|
'error' => true, |
|
2101
|
2101
|
'mfaData' => $ret, |
|
2102
|
2102
|
'mfaQRCodeInfos' => false, |
|
2103
|
2103
|
]; |
|
2104
|
|
- } else if ($ret['duo_url_ready'] === true){ |
|
|
2104
|
+ } else if ($ret['duo_url_ready'] === true) { |
|
2105
|
2105
|
return [ |
|
2106
|
2106
|
'error' => false, |
|
2107
|
2107
|
'mfaData' => $ret, |