1
|
<?php
|
2
|
/*
|
3
|
* system_usermanager.php
|
4
|
*
|
5
|
* part of pfSense (https://www.pfsense.org)
|
6
|
* Copyright (c) 2004-2013 BSD Perimeter
|
7
|
* Copyright (c) 2013-2016 Electric Sheep Fencing
|
8
|
* Copyright (c) 2014-2024 Rubicon Communications, LLC (Netgate)
|
9
|
* Copyright (c) 2008 Shrew Soft Inc.
|
10
|
* Copyright (c) 2005 Paul Taylor <paultaylor@winn-dixie.com>
|
11
|
* All rights reserved.
|
12
|
*
|
13
|
* originally based on m0n0wall (http://m0n0.ch/wall)
|
14
|
* Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
15
|
* All rights reserved.
|
16
|
*
|
17
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
18
|
* you may not use this file except in compliance with the License.
|
19
|
* You may obtain a copy of the License at
|
20
|
*
|
21
|
* http://www.apache.org/licenses/LICENSE-2.0
|
22
|
*
|
23
|
* Unless required by applicable law or agreed to in writing, software
|
24
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
25
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
26
|
* See the License for the specific language governing permissions and
|
27
|
* limitations under the License.
|
28
|
*/
|
29
|
|
30
|
##|+PRIV
|
31
|
##|*IDENT=page-system-usermanager
|
32
|
##|*NAME=System: User Manager
|
33
|
##|*DESCR=Allow access to the 'System: User Manager' page.
|
34
|
##|*WARN=standard-warning-root
|
35
|
##|*MATCH=system_usermanager.php*
|
36
|
##|-PRIV
|
37
|
|
38
|
require_once("certs.inc");
|
39
|
require_once("guiconfig.inc");
|
40
|
require_once("pfsense-utils.inc");
|
41
|
|
42
|
$logging_level = LOG_WARNING;
|
43
|
$logging_prefix = gettext("Local User Database");
|
44
|
$cert_keylens = array("1024", "2048", "3072", "4096", "6144", "7680", "8192", "15360", "16384");
|
45
|
$cert_keytypes = array("RSA", "ECDSA");
|
46
|
$openssl_ecnames = cert_build_curve_list();
|
47
|
|
48
|
global $openssl_digest_algs;
|
49
|
|
50
|
$password_extra_help = get_validate_password_hints();
|
51
|
|
52
|
// start admin user code
|
53
|
if (isset($_REQUEST['userid']) && is_numericint($_REQUEST['userid'])) {
|
54
|
$id = $_REQUEST['userid'];
|
55
|
}
|
56
|
|
57
|
config_init_path('system/user');
|
58
|
$act = $_REQUEST['act'];
|
59
|
|
60
|
if (isset($_SERVER['HTTP_REFERER'])) {
|
61
|
$referer = $_SERVER['HTTP_REFERER'];
|
62
|
} else {
|
63
|
$referer = '/system_usermanager.php';
|
64
|
}
|
65
|
|
66
|
if (isset($id)) {
|
67
|
$this_user = config_get_path("system/user/{$id}");
|
68
|
}
|
69
|
if ($this_user) {
|
70
|
$pconfig['usernamefld'] = $this_user['name'];
|
71
|
$pconfig['descr'] = $this_user['descr'];
|
72
|
$pconfig['expires'] = $this_user['expires'];
|
73
|
$pconfig['customsettings'] = isset($this_user['customsettings']);
|
74
|
$pconfig['webguicss'] = $this_user['webguicss'];
|
75
|
$pconfig['webguifixedmenu'] = $this_user['webguifixedmenu'];
|
76
|
$pconfig['webguihostnamemenu'] = $this_user['webguihostnamemenu'];
|
77
|
$pconfig['dashboardcolumns'] = $this_user['dashboardcolumns'];
|
78
|
$pconfig['interfacessort'] = isset($this_user['interfacessort']);
|
79
|
$pconfig['dashboardavailablewidgetspanel'] = isset($this_user['dashboardavailablewidgetspanel']);
|
80
|
$pconfig['systemlogsfilterpanel'] = isset($this_user['systemlogsfilterpanel']);
|
81
|
$pconfig['systemlogsmanagelogpanel'] = isset($this_user['systemlogsmanagelogpanel']);
|
82
|
$pconfig['statusmonitoringsettingspanel'] = isset($this_user['statusmonitoringsettingspanel']);
|
83
|
$pconfig['webguileftcolumnhyper'] = isset($this_user['webguileftcolumnhyper']);
|
84
|
$pconfig['disablealiaspopupdetail'] = isset($this_user['disablealiaspopupdetail']);
|
85
|
$pconfig['pagenamefirst'] = isset($this_user['pagenamefirst']);
|
86
|
$pconfig['groups'] = local_user_get_groups($this_user);
|
87
|
$pconfig['utype'] = $this_user['scope'];
|
88
|
$pconfig['uid'] = $this_user['uid'];
|
89
|
$pconfig['authorizedkeys'] = base64_decode($this_user['authorizedkeys']);
|
90
|
$pconfig['priv'] = $this_user['priv'];
|
91
|
$pconfig['ipsecpsk'] = $this_user['ipsecpsk'];
|
92
|
$pconfig['disabled'] = isset($this_user['disabled']);
|
93
|
$pconfig['keephistory'] = isset($this_user['keephistory']);
|
94
|
}
|
95
|
|
96
|
/*
|
97
|
* Check user privileges to test if the user is allowed to make changes.
|
98
|
* Otherwise users can end up in an inconsistent state where some changes are
|
99
|
* performed and others denied. See https://redmine.pfsense.org/issues/9259
|
100
|
*/
|
101
|
phpsession_begin();
|
102
|
$guiuser = getUserEntry($_SESSION['Username']);
|
103
|
$guiuser = $guiuser['item'];
|
104
|
$read_only = (is_array($guiuser) && userHasPrivilege($guiuser, "user-config-readonly"));
|
105
|
phpsession_end();
|
106
|
|
107
|
if (!empty($_POST) && $read_only) {
|
108
|
$input_errors = array(gettext("Insufficient privileges to make the requested change (read only)."));
|
109
|
}
|
110
|
|
111
|
if (($_POST['act'] == "deluser") && !$read_only) {
|
112
|
|
113
|
if (!isset($_POST['username']) || !isset($id) || (config_get_path("system/user/{$id}") === null) || ($_POST['username'] != config_get_path("system/user/{$id}/name"))) {
|
114
|
pfSenseHeader("system_usermanager.php");
|
115
|
exit;
|
116
|
}
|
117
|
|
118
|
if ($_POST['username'] == $_SESSION['Username']) {
|
119
|
$delete_errors[] = sprintf(gettext("Cannot delete user %s because you are currently logged in as that user."), $_POST['username']);
|
120
|
} else {
|
121
|
local_user_del(config_get_path("system/user/{$id}"));
|
122
|
$userdeleted = config_get_path("system/user/{$id}/name");
|
123
|
config_del_path("system/user/{$id}");
|
124
|
/* Reindex the array to avoid operating on an incorrect index https://redmine.pfsense.org/issues/7733 */
|
125
|
config_set_path('system/user', array_values(config_get_path('system/user')));
|
126
|
$savemsg = sprintf(gettext("Successfully deleted user: %s"), $userdeleted);
|
127
|
write_config($savemsg);
|
128
|
syslog($logging_level, "{$logging_prefix}: {$savemsg}");
|
129
|
}
|
130
|
|
131
|
} else if ($act == "new") {
|
132
|
/*
|
133
|
* set this value cause the text field is read only
|
134
|
* and the user should not be able to mess with this
|
135
|
* setting.
|
136
|
*/
|
137
|
$pconfig['utype'] = "user";
|
138
|
$pconfig['lifetime'] = 3650;
|
139
|
|
140
|
$nonPrvCas = array();
|
141
|
foreach (config_get_path('ca', []) as $ca) {
|
142
|
if (!$ca['prv']) {
|
143
|
continue;
|
144
|
}
|
145
|
|
146
|
$nonPrvCas[ $ca['refid'] ] = $ca['descr'];
|
147
|
}
|
148
|
|
149
|
}
|
150
|
|
151
|
if (isset($_POST['dellall']) && !$read_only) {
|
152
|
|
153
|
$del_users = $_POST['delete_check'];
|
154
|
$deleted_users = array();
|
155
|
|
156
|
if (!empty($del_users)) {
|
157
|
foreach ($del_users as $userid) {
|
158
|
$tmp_user = config_get_path("system/user/{$userid}", []);
|
159
|
if ($tmp_user['scope'] != "system") {
|
160
|
if ($tmp_user['name'] == $_SESSION['Username']) {
|
161
|
$delete_errors[] = sprintf(gettext("Cannot delete user %s because you are currently logged in as that user."), $tmp_user['name']);
|
162
|
} else {
|
163
|
$deleted_users[] = $tmp_user['name'];
|
164
|
local_user_del($tmp_user);
|
165
|
config_del_path("system/user/{$userid}");
|
166
|
}
|
167
|
} else {
|
168
|
$delete_errors[] = sprintf(gettext("Cannot delete user %s because it is a system user."), $tmp_user['name']);
|
169
|
}
|
170
|
}
|
171
|
|
172
|
if (count($deleted_users) > 0) {
|
173
|
$savemsg = sprintf(gettext("Successfully deleted %s: %s"), (count($deleted_users) == 1) ? gettext("user") : gettext("users"), implode(', ', $deleted_users));
|
174
|
/* Reindex the array to avoid operating on an incorrect index https://redmine.pfsense.org/issues/7733 */
|
175
|
config_set_path('system/user', array_values(config_get_path('system/user')));
|
176
|
write_config($savemsg);
|
177
|
syslog($logging_level, "{$logging_prefix}: {$savemsg}");
|
178
|
}
|
179
|
}
|
180
|
}
|
181
|
|
182
|
if (($_POST['act'] == "delcert") && !$read_only) {
|
183
|
|
184
|
if (!isset($id) || !config_get_path("system/user/{$id}")) {
|
185
|
pfSenseHeader("system_usermanager.php");
|
186
|
exit;
|
187
|
}
|
188
|
|
189
|
$certdeleted = lookup_cert(config_get_path("system/user/{$id}/cert/{$_POST['certid']}"));
|
190
|
$certdeleted = $certdeleted['item']['descr'];
|
191
|
$savemsg = sprintf(gettext("Removed certificate association \"%s\" from user %s"), $certdeleted, config_get_path("system/user/{$id}/name"));
|
192
|
config_del_path("system/user/{$id}/cert/{$_POST['certid']}");
|
193
|
write_config($savemsg);
|
194
|
syslog($logging_level, "{$logging_prefix}: {$savemsg}");
|
195
|
$_POST['act'] = "edit";
|
196
|
}
|
197
|
|
198
|
if (($_POST['act'] == "delprivid") && !$read_only && isset($id)) {
|
199
|
$privdeleted = array_get_path($priv_list, (config_get_path("system/user/{$id}/priv/{$_POST['privid']}") . '/name'));
|
200
|
config_del_path("system/user/{$id}/priv/{$_POST['privid']}");
|
201
|
local_user_set(config_get_path("system/user/{$id}"));
|
202
|
$savemsg = sprintf(gettext("Removed Privilege \"%s\" from user %s"), $privdeleted, config_get_path("system/user/{$id}/name"));
|
203
|
write_config($savemsg);
|
204
|
syslog($logging_level, "{$logging_prefix}: {$savemsg}");
|
205
|
$_POST['act'] = "edit";
|
206
|
}
|
207
|
|
208
|
if ($_POST['save'] && !$read_only) {
|
209
|
unset($input_errors);
|
210
|
$input_errors = [];
|
211
|
$pconfig = $_POST;
|
212
|
|
213
|
/* input validation */
|
214
|
if (isset($id) && config_get_path("system/user/{$id}")) {
|
215
|
$reqdfields = explode(" ", "usernamefld");
|
216
|
$reqdfieldsn = array(gettext("Username"));
|
217
|
} else {
|
218
|
if (empty($_POST['name'])) {
|
219
|
$reqdfields = explode(" ", "usernamefld passwordfld1");
|
220
|
$reqdfieldsn = array(
|
221
|
gettext("Username"),
|
222
|
gettext("Password"));
|
223
|
} else {
|
224
|
$reqdfields = explode(" ", "usernamefld passwordfld1 name caref keylen lifetime");
|
225
|
$reqdfieldsn = array(
|
226
|
gettext("Username"),
|
227
|
gettext("Password"),
|
228
|
gettext("Descriptive name"),
|
229
|
gettext("Certificate authority"),
|
230
|
gettext("Key length"),
|
231
|
gettext("Lifetime"));
|
232
|
}
|
233
|
}
|
234
|
|
235
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
|
236
|
|
237
|
if (preg_match("/[^a-zA-Z0-9\.\-_]/", $_POST['usernamefld'])) {
|
238
|
$input_errors[] = gettext("The username contains invalid characters.");
|
239
|
}
|
240
|
|
241
|
if (strlen($_POST['usernamefld']) > 32) {
|
242
|
$input_errors[] = gettext("The username is longer than 32 characters.");
|
243
|
}
|
244
|
|
245
|
if (($_POST['passwordfld1']) && ($_POST['passwordfld1'] != $_POST['passwordfld2'])) {
|
246
|
$input_errors[] = gettext("The passwords do not match.");
|
247
|
}
|
248
|
|
249
|
if (isset($_POST['ipsecpsk']) && !preg_match('/^[[:ascii:]]*$/', $_POST['ipsecpsk'])) {
|
250
|
$input_errors[] = gettext("IPsec Pre-Shared Key contains invalid characters.");
|
251
|
}
|
252
|
|
253
|
$input_errors = array_merge($input_errors, validate_password($_POST['usernamefld'], $_POST['passwordfld1']));
|
254
|
|
255
|
/* Check the POSTed groups to ensure they are valid and exist */
|
256
|
if (is_array($_POST['groups'])) {
|
257
|
foreach ($_POST['groups'] as $newgroup) {
|
258
|
if (empty(getGroupEntry($newgroup))) {
|
259
|
$input_errors[] = gettext("One or more invalid groups was submitted.");
|
260
|
}
|
261
|
}
|
262
|
}
|
263
|
|
264
|
$oldusername = (isset($id)) ? config_get_path("system/user/{$id}/name", '') : '';
|
265
|
/* make sure this user name is unique */
|
266
|
if (!$input_errors) {
|
267
|
foreach (config_get_path('system/user', []) as $userent) {
|
268
|
if ($userent['name'] == $_POST['usernamefld'] && $oldusername != $_POST['usernamefld']) {
|
269
|
$input_errors[] = gettext("Another entry with the same username already exists.");
|
270
|
break;
|
271
|
}
|
272
|
}
|
273
|
}
|
274
|
/* also make sure it is not reserved */
|
275
|
if (!$input_errors) {
|
276
|
$system_users = explode("\n", file_get_contents("/etc/passwd"));
|
277
|
foreach ($system_users as $s_user) {
|
278
|
$ent = explode(":", $s_user);
|
279
|
if ($ent[0] == $_POST['usernamefld'] && $oldusername != $_POST['usernamefld']) {
|
280
|
$input_errors[] = gettext("That username is reserved by the system.");
|
281
|
break;
|
282
|
}
|
283
|
}
|
284
|
}
|
285
|
|
286
|
/*
|
287
|
* Check for a valid expiration date if one is set at all (valid means,
|
288
|
* DateTime puts out a time stamp so any DateTime compatible time
|
289
|
* format may be used. to keep it simple for the enduser, we only
|
290
|
* claim to accept MM/DD/YYYY as inputs. Advanced users may use inputs
|
291
|
* like "+1 day", which will be converted to MM/DD/YYYY based on "now".
|
292
|
* Otherwise such an entry would lead to an invalid expiration data.
|
293
|
*/
|
294
|
if ($_POST['expires']) {
|
295
|
try {
|
296
|
$expdate = new DateTime($_POST['expires']);
|
297
|
//convert from any DateTime compatible date to MM/DD/YYYY
|
298
|
$_POST['expires'] = $expdate->format("m/d/Y");
|
299
|
} catch (Exception $ex) {
|
300
|
$input_errors[] = gettext("Invalid expiration date format; use MM/DD/YYYY instead.");
|
301
|
}
|
302
|
}
|
303
|
|
304
|
if (!empty($_POST['name'])) {
|
305
|
$ca = lookup_ca($_POST['caref']);
|
306
|
$ca = $ca['item'];
|
307
|
if (!$ca) {
|
308
|
$input_errors[] = gettext("Invalid internal Certificate Authority") . "\n";
|
309
|
}
|
310
|
}
|
311
|
validate_webguicss_field($input_errors, $_POST['webguicss']);
|
312
|
validate_webguifixedmenu_field($input_errors, $_POST['webguifixedmenu']);
|
313
|
validate_webguihostnamemenu_field($input_errors, $_POST['webguihostnamemenu']);
|
314
|
validate_dashboardcolumns_field($input_errors, $_POST['dashboardcolumns']);
|
315
|
|
316
|
if (!$input_errors) {
|
317
|
if (isset($id) && config_get_path("system/user/{$id}")) {
|
318
|
$user_item_config = [
|
319
|
'idx' => $id,
|
320
|
'item' => config_get_path("system/user/{$id}")
|
321
|
];
|
322
|
} else {
|
323
|
$user_item_config = ['idx' => null, 'item' => null];
|
324
|
}
|
325
|
$userent = &$user_item_config['item'];
|
326
|
|
327
|
isset($_POST['utype']) ? $userent['scope'] = $_POST['utype'] : $userent['scope'] = "system";
|
328
|
|
329
|
/* the user name was modified */
|
330
|
if (!empty($_POST['oldusername']) && ($_POST['usernamefld'] <> $_POST['oldusername'])) {
|
331
|
$_SERVER['REMOTE_USER'] = $_POST['usernamefld'];
|
332
|
local_user_del($userent);
|
333
|
}
|
334
|
|
335
|
/* the user password was modified */
|
336
|
if ($_POST['passwordfld1']) {
|
337
|
local_user_set_password($user_item_config, $_POST['passwordfld1']);
|
338
|
}
|
339
|
|
340
|
/* only change description if sent */
|
341
|
if (isset($_POST['descr'])) {
|
342
|
$userent['descr'] = $_POST['descr'];
|
343
|
}
|
344
|
|
345
|
$userent['name'] = $_POST['usernamefld'];
|
346
|
$userent['expires'] = $_POST['expires'];
|
347
|
$userent['dashboardcolumns'] = $_POST['dashboardcolumns'];
|
348
|
$userent['authorizedkeys'] = base64_encode($_POST['authorizedkeys']);
|
349
|
$userent['ipsecpsk'] = $_POST['ipsecpsk'];
|
350
|
|
351
|
if ($_POST['disabled']) {
|
352
|
$userent['disabled'] = true;
|
353
|
} else {
|
354
|
unset($userent['disabled']);
|
355
|
}
|
356
|
|
357
|
if ($_POST['customsettings']) {
|
358
|
$userent['customsettings'] = true;
|
359
|
} else {
|
360
|
unset($userent['customsettings']);
|
361
|
}
|
362
|
|
363
|
if ($_POST['webguicss']) {
|
364
|
$userent['webguicss'] = $_POST['webguicss'];
|
365
|
} else {
|
366
|
unset($userent['webguicss']);
|
367
|
}
|
368
|
|
369
|
if ($_POST['webguifixedmenu']) {
|
370
|
$userent['webguifixedmenu'] = $_POST['webguifixedmenu'];
|
371
|
} else {
|
372
|
unset($userent['webguifixedmenu']);
|
373
|
}
|
374
|
|
375
|
if ($_POST['webguihostnamemenu']) {
|
376
|
$userent['webguihostnamemenu'] = $_POST['webguihostnamemenu'];
|
377
|
} else {
|
378
|
unset($userent['webguihostnamemenu']);
|
379
|
}
|
380
|
|
381
|
if ($_POST['interfacessort']) {
|
382
|
$userent['interfacessort'] = true;
|
383
|
} else {
|
384
|
unset($userent['interfacessort']);
|
385
|
}
|
386
|
|
387
|
if ($_POST['dashboardavailablewidgetspanel']) {
|
388
|
$userent['dashboardavailablewidgetspanel'] = true;
|
389
|
} else {
|
390
|
unset($userent['dashboardavailablewidgetspanel']);
|
391
|
}
|
392
|
|
393
|
if ($_POST['systemlogsfilterpanel']) {
|
394
|
$userent['systemlogsfilterpanel'] = true;
|
395
|
} else {
|
396
|
unset($userent['systemlogsfilterpanel']);
|
397
|
}
|
398
|
|
399
|
if ($_POST['systemlogsmanagelogpanel']) {
|
400
|
$userent['systemlogsmanagelogpanel'] = true;
|
401
|
} else {
|
402
|
unset($userent['systemlogsmanagelogpanel']);
|
403
|
}
|
404
|
|
405
|
if ($_POST['statusmonitoringsettingspanel']) {
|
406
|
$userent['statusmonitoringsettingspanel'] = true;
|
407
|
} else {
|
408
|
unset($userent['statusmonitoringsettingspanel']);
|
409
|
}
|
410
|
|
411
|
if ($_POST['webguileftcolumnhyper']) {
|
412
|
$userent['webguileftcolumnhyper'] = true;
|
413
|
} else {
|
414
|
unset($userent['webguileftcolumnhyper']);
|
415
|
}
|
416
|
|
417
|
if ($_POST['disablealiaspopupdetail']) {
|
418
|
$userent['disablealiaspopupdetail'] = true;
|
419
|
} else {
|
420
|
unset($userent['disablealiaspopupdetail']);
|
421
|
}
|
422
|
|
423
|
if ($_POST['pagenamefirst']) {
|
424
|
$userent['pagenamefirst'] = true;
|
425
|
} else {
|
426
|
unset($userent['pagenamefirst']);
|
427
|
}
|
428
|
|
429
|
if ($_POST['keephistory']) {
|
430
|
$userent['keephistory'] = true;
|
431
|
} else {
|
432
|
unset($userent['keephistory']);
|
433
|
}
|
434
|
|
435
|
if (isset($id) && config_get_path("system/user/{$id}")) {
|
436
|
config_set_path("system/user/{$id}", $userent);
|
437
|
} else {
|
438
|
if (!empty($_POST['name'])) {
|
439
|
$cert = array();
|
440
|
$cert['refid'] = uniqid();
|
441
|
$userent['cert'] = array();
|
442
|
|
443
|
$cert['descr'] = $_POST['name'];
|
444
|
|
445
|
$subject = cert_get_subject_hash($ca['crt']);
|
446
|
|
447
|
$dn = array();
|
448
|
if (!empty($subject['C'])) {
|
449
|
$dn['countryName'] = $subject['C'];
|
450
|
}
|
451
|
if (!empty($subject['ST'])) {
|
452
|
$dn['stateOrProvinceName'] = $subject['ST'];
|
453
|
}
|
454
|
if (!empty($subject['L'])) {
|
455
|
$dn['localityName'] = $subject['L'];
|
456
|
}
|
457
|
if (!empty($subject['O'])) {
|
458
|
$dn['organizationName'] = $subject['O'];
|
459
|
}
|
460
|
if (!empty($subject['OU'])) {
|
461
|
$dn['organizationalUnitName'] = $subject['OU'];
|
462
|
}
|
463
|
$dn['commonName'] = $userent['name'];
|
464
|
$cn_altname = cert_add_altname_type($userent['name']);
|
465
|
if (!empty($cn_altname)) {
|
466
|
$dn['subjectAltName'] = $cn_altname;
|
467
|
}
|
468
|
|
469
|
cert_create($cert, $_POST['caref'], $_POST['keylen'],
|
470
|
(int)$_POST['lifetime'], $dn, 'user',
|
471
|
$_POST['digest_alg'], $_POST['keytype'],
|
472
|
$_POST['ecname']);
|
473
|
|
474
|
config_set_path('cert/', $cert);
|
475
|
$userent['cert'][] = $cert['refid'];
|
476
|
}
|
477
|
$nextuid_config = config_get_path('system/nextuid');
|
478
|
$userent['uid'] = $nextuid_config++;
|
479
|
config_set_path('system/nextuid', $nextuid_config);
|
480
|
/* Add the user to All Users group. */
|
481
|
$group_config = config_get_path('system/group', []);
|
482
|
foreach ($group_config as $gidx => &$group) {
|
483
|
if ($group['name'] == "all") {
|
484
|
if (!is_array($group['member'])) {
|
485
|
$group['member'] = [];
|
486
|
}
|
487
|
$group['member'][] = $userent['uid'];
|
488
|
break;
|
489
|
}
|
490
|
}
|
491
|
unset($group);
|
492
|
config_set_path('system/group', $group_config);
|
493
|
|
494
|
config_set_path('system/user/', $userent);
|
495
|
}
|
496
|
|
497
|
/* Sort it alphabetically */
|
498
|
$user_config = config_get_path('system/user');
|
499
|
usort($user_config, function($a, $b) {
|
500
|
return strcmp($a['name'], $b['name']);
|
501
|
});
|
502
|
config_set_path('system/user', $user_config);
|
503
|
|
504
|
local_user_set_groups($userent, $_POST['groups']);
|
505
|
local_user_set($userent);
|
506
|
|
507
|
/* Update user index to account for new changes */
|
508
|
global $userindex;
|
509
|
$userindex = index_users();
|
510
|
|
511
|
$savemsg = sprintf(gettext("Successfully %s user %s"), (isset($id)) ? gettext("edited") : gettext("created"), $userent['name']);
|
512
|
write_config($savemsg);
|
513
|
syslog($logging_level, "{$logging_prefix}: {$savemsg}");
|
514
|
if (is_dir("/etc/inc/privhooks")) {
|
515
|
run_plugins("/etc/inc/privhooks");
|
516
|
}
|
517
|
|
518
|
if ($userent['uid'] == 0) {
|
519
|
log_error(gettext("Restarting sshd due to admin account change."));
|
520
|
send_event("service restart sshd");
|
521
|
}
|
522
|
|
523
|
pfSenseHeader("system_usermanager.php");
|
524
|
}
|
525
|
}
|
526
|
|
527
|
function build_priv_table() {
|
528
|
global $id, $read_only;
|
529
|
|
530
|
$privhtml = '<div class="table-responsive">';
|
531
|
$privhtml .= '<table class="table table-striped table-hover table-condensed">';
|
532
|
$privhtml .= '<thead>';
|
533
|
$privhtml .= '<tr>';
|
534
|
$privhtml .= '<th>' . gettext('Inherited from') . '</th>';
|
535
|
$privhtml .= '<th>' . gettext('Name') . '</th>';
|
536
|
$privhtml .= '<th>' . gettext('Description') . '</th>';
|
537
|
$privhtml .= '<th>' . gettext('Action') . '</th>';
|
538
|
$privhtml .= '</tr>';
|
539
|
$privhtml .= '</thead>';
|
540
|
$privhtml .= '<tbody>';
|
541
|
|
542
|
$i = 0;
|
543
|
$user_has_root_priv = false;
|
544
|
|
545
|
$user_privs = (is_numericint($id)) ? get_user_privdesc(config_get_path("system/user/{$id}", [])) : [];
|
546
|
foreach ($user_privs as $priv) {
|
547
|
$group = false;
|
548
|
if ($priv['group']) {
|
549
|
$group = $priv['group'];
|
550
|
}
|
551
|
|
552
|
$privhtml .= '<tr>';
|
553
|
$privhtml .= '<td>' . htmlspecialchars($priv['group']) . '</td>';
|
554
|
$privhtml .= '<td>' . htmlspecialchars($priv['name']) . '</td>';
|
555
|
$privhtml .= '<td>' . htmlspecialchars($priv['descr']);
|
556
|
if (isset($priv['warn']) && ($priv['warn'] == 'standard-warning-root')) {
|
557
|
$privhtml .= ' ' . gettext('(admin privilege)');
|
558
|
$user_has_root_priv = true;
|
559
|
}
|
560
|
$privhtml .= '</td>';
|
561
|
$privhtml .= '<td>';
|
562
|
if (!$group && !$read_only) {
|
563
|
$privhtml .= '<a class="fa-solid fa-trash-can no-confirm icon-pointer" title="' . gettext('Delete Privilege') . '" id="delprivid' . $i . '"></a>';
|
564
|
}
|
565
|
|
566
|
$privhtml .= '</td>';
|
567
|
$privhtml .= '</tr>';
|
568
|
|
569
|
if (!$group) {
|
570
|
$i++;
|
571
|
}
|
572
|
}
|
573
|
|
574
|
if ($user_has_root_priv) {
|
575
|
$privhtml .= '<tr>';
|
576
|
$privhtml .= '<td colspan="3">';
|
577
|
$privhtml .= '<b>' . gettext('Security notice: This user effectively has administrator-level access') . '</b>';
|
578
|
$privhtml .= '</td>';
|
579
|
$privhtml .= '<td>';
|
580
|
$privhtml .= '</td>';
|
581
|
$privhtml .= '</tr>';
|
582
|
|
583
|
}
|
584
|
|
585
|
$privhtml .= '</tbody>';
|
586
|
$privhtml .= '</table>';
|
587
|
$privhtml .= '</div>';
|
588
|
|
589
|
$privhtml .= '<nav class="action-buttons">';
|
590
|
if (!$read_only) {
|
591
|
$privhtml .= '<a href="system_usermanager_addprivs.php?userid=' . $id . '" class="btn btn-success"><i class="fa-solid fa-plus icon-embed-btn"></i>' . gettext("Add") . '</a>';
|
592
|
}
|
593
|
$privhtml .= '</nav>';
|
594
|
|
595
|
return($privhtml);
|
596
|
}
|
597
|
|
598
|
function build_cert_table() {
|
599
|
global $id, $read_only;
|
600
|
|
601
|
$certhtml = '<div class="table-responsive">';
|
602
|
$certhtml .= '<table class="table table-striped table-hover table-condensed">';
|
603
|
$certhtml .= '<thead>';
|
604
|
$certhtml .= '<tr>';
|
605
|
$certhtml .= '<th>' . gettext('Name') . '</th>';
|
606
|
$certhtml .= '<th>' . gettext('CA') . '</th>';
|
607
|
$certhtml .= '<th></th>';
|
608
|
$certhtml .= '</tr>';
|
609
|
$certhtml .= '</thead>';
|
610
|
$certhtml .= '<tbody>';
|
611
|
|
612
|
$i = 0;
|
613
|
$user_certs = (is_numericint($id)) ? config_get_path("system/user/{$id}/cert", []) : [];
|
614
|
foreach ($user_certs as $certref) {
|
615
|
$cert = lookup_cert($certref);
|
616
|
$cert = $cert['item'];
|
617
|
$ca = lookup_ca($cert['caref']);
|
618
|
$ca = $ca['item'];
|
619
|
$revokedstr = is_cert_revoked($cert) ? '<b> Revoked</b>':'';
|
620
|
|
621
|
$certhtml .= '<tr>';
|
622
|
$certhtml .= '<td>' . htmlspecialchars($cert['descr']) . $revokedstr . '</td>';
|
623
|
$certhtml .= '<td>' . htmlspecialchars($ca['descr']) . '</td>';
|
624
|
$certhtml .= '<td>';
|
625
|
if (!$read_only) {
|
626
|
$certhtml .= '<a id="delcert' . $i .'" class="fa-solid fa-trash-can no-confirm icon-pointer" title="';
|
627
|
$certhtml .= gettext('Remove this certificate association? (Certificate will not be deleted)') . '"></a>';
|
628
|
}
|
629
|
$certhtml .= '</td>';
|
630
|
$certhtml .= '</tr>';
|
631
|
$i++;
|
632
|
}
|
633
|
|
634
|
$certhtml .= '</tbody>';
|
635
|
$certhtml .= '</table>';
|
636
|
$certhtml .= '</div>';
|
637
|
|
638
|
$certhtml .= '<nav class="action-buttons">';
|
639
|
if (!$read_only && is_numericint($id)) {
|
640
|
$certhtml .= '<a href="system_certmanager.php?act=new&userid=' . $id . '" class="btn btn-success"><i class="fa-solid fa-plus icon-embed-btn"></i>' . gettext("Add") . '</a>';
|
641
|
}
|
642
|
$certhtml .= '</nav>';
|
643
|
|
644
|
return($certhtml);
|
645
|
}
|
646
|
|
647
|
$pgtitle = array(gettext("System"), gettext("User Manager"), gettext("Users"));
|
648
|
$pglinks = array("", "system_usermanager.php", "system_usermanager.php");
|
649
|
|
650
|
if ($act == "new" || $act == "edit" || $input_errors) {
|
651
|
$pgtitle[] = gettext('Edit');
|
652
|
$pglinks[] = "@self";
|
653
|
}
|
654
|
|
655
|
include("head.inc");
|
656
|
|
657
|
if ($delete_errors) {
|
658
|
print_input_errors($delete_errors);
|
659
|
}
|
660
|
|
661
|
if ($input_errors) {
|
662
|
print_input_errors($input_errors);
|
663
|
}
|
664
|
|
665
|
if ($savemsg) {
|
666
|
print_info_box($savemsg, 'success');
|
667
|
}
|
668
|
|
669
|
$tab_array = array();
|
670
|
$tab_array[] = array(gettext("Users"), true, "system_usermanager.php");
|
671
|
$tab_array[] = array(gettext("Groups"), false, "system_groupmanager.php");
|
672
|
$tab_array[] = array(gettext("Settings"), false, "system_usermanager_settings.php");
|
673
|
$tab_array[] = array(gettext("Change Password"), false, "system_usermanager_passwordmg.php");
|
674
|
$tab_array[] = array(gettext("Authentication Servers"), false, "system_authservers.php");
|
675
|
display_top_tabs($tab_array);
|
676
|
|
677
|
if (!($act == "new" || $act == "edit" || $input_errors)) {
|
678
|
?>
|
679
|
<form method="post">
|
680
|
<div class="panel panel-default">
|
681
|
<div class="panel-heading"><h2 class="panel-title"><?=gettext('Users')?></h2></div>
|
682
|
<div class="panel-body">
|
683
|
<div class="table-responsive">
|
684
|
<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap table-rowdblclickedit" data-sortable>
|
685
|
<thead>
|
686
|
<tr>
|
687
|
<th> </th>
|
688
|
<th><?=gettext("Username")?></th>
|
689
|
<th><?=gettext("Full name")?></th>
|
690
|
<th><?=gettext("Status")?></th>
|
691
|
<th><?=gettext("Groups")?></th>
|
692
|
<th><?=gettext("Actions")?></th>
|
693
|
</tr>
|
694
|
</thead>
|
695
|
<tbody>
|
696
|
<?php
|
697
|
foreach (config_get_path('system/user', []) as $i => $userent):
|
698
|
?>
|
699
|
<tr>
|
700
|
<td>
|
701
|
<input type="checkbox" id="frc<?=$i?>" name="delete_check[]" value="<?=$i?>" <?=((($userent['scope'] == "system") || ($userent['name'] == $_SESSION['Username'])) ? 'disabled' : '')?>/>
|
702
|
</td>
|
703
|
<td>
|
704
|
<?php
|
705
|
if ($userent['scope'] != "user") {
|
706
|
$usrimg = 'fa-regular fa-eye';
|
707
|
} else {
|
708
|
$usrimg = 'fa-solid fa-user';
|
709
|
}
|
710
|
?>
|
711
|
<i class="<?=$usrimg?>" title="<?= gettext("Scope") . ": {$userent['scope']}" ?>"></i>
|
712
|
<?=htmlspecialchars($userent['name'])?>
|
713
|
</td>
|
714
|
<td><?=htmlspecialchars($userent['descr'])?></td>
|
715
|
<td><i class="<?= (isset($userent['disabled'])) ? 'fa-solid fa-ban" title="' . gettext("Disabled") . '"' : 'fa-solid fa-check" title="' . gettext("Enabled") . '"' ; ?>"><span style='display: none'><?= (isset($userent['disabled'])) ? gettext("Disabled") : gettext("Enabled") ; ?></span></i></td>
|
716
|
<td><?=implode(",", local_user_get_groups($userent))?></td>
|
717
|
<td>
|
718
|
<a class="fa-solid fa-pencil" title="<?=gettext("Edit user"); ?>" href="?act=edit&userid=<?=$i?>"></a>
|
719
|
<?php if (($userent['scope'] != "system") && ($userent['name'] != $_SESSION['Username']) && !$read_only): ?>
|
720
|
<a class="fa-solid fa-trash-can" title="<?=gettext("Delete user")?>" href="?act=deluser&userid=<?=$i?>&username=<?=$userent['name']?>" usepost></a>
|
721
|
<?php endif; ?>
|
722
|
</td>
|
723
|
</tr>
|
724
|
<?php endforeach; ?>
|
725
|
</tbody>
|
726
|
</table>
|
727
|
</div>
|
728
|
</div>
|
729
|
</div>
|
730
|
<nav class="action-buttons">
|
731
|
<?php if (!$read_only): ?>
|
732
|
|
733
|
<a href="?act=new" class="btn btn-sm btn-success">
|
734
|
<i class="fa-solid fa-plus icon-embed-btn"></i>
|
735
|
<?=gettext("Add")?>
|
736
|
</a>
|
737
|
|
738
|
<button type="submit" class="btn btn-sm btn-danger" name="dellall" value="dellall" title="<?=gettext('Delete selected users')?>">
|
739
|
<i class="fa-solid fa-trash-can icon-embed-btn"></i>
|
740
|
<?=gettext("Delete")?>
|
741
|
</button>
|
742
|
<?php endif; ?>
|
743
|
|
744
|
</nav>
|
745
|
</form>
|
746
|
<div class="infoblock">
|
747
|
<?php
|
748
|
print_callout('<p>' . gettext("Additional users can be added here. User permissions for accessing " .
|
749
|
"the webConfigurator can be assigned directly or inherited from group memberships. " .
|
750
|
"Some system object properties can be modified but they cannot be deleted.") . '</p>' .
|
751
|
'<p>' . gettext("Accounts added here are also used for other parts of the system " .
|
752
|
"such as OpenVPN, IPsec, and Captive Portal.") . '</p>'
|
753
|
);
|
754
|
|
755
|
?></div>
|
756
|
|
757
|
<?php
|
758
|
include("foot.inc");
|
759
|
exit;
|
760
|
}
|
761
|
|
762
|
$form = new Form;
|
763
|
|
764
|
if ($act == "new" || $act == "edit" || $input_errors):
|
765
|
|
766
|
$form->addGlobal(new Form_Input(
|
767
|
'act',
|
768
|
null,
|
769
|
'hidden',
|
770
|
''
|
771
|
));
|
772
|
|
773
|
$form->addGlobal(new Form_Input(
|
774
|
'userid',
|
775
|
null,
|
776
|
'hidden',
|
777
|
isset($id) ? $id:''
|
778
|
));
|
779
|
|
780
|
$form->addGlobal(new Form_Input(
|
781
|
'privid',
|
782
|
null,
|
783
|
'hidden',
|
784
|
''
|
785
|
));
|
786
|
|
787
|
$form->addGlobal(new Form_Input(
|
788
|
'certid',
|
789
|
null,
|
790
|
'hidden',
|
791
|
''
|
792
|
));
|
793
|
|
794
|
$ro = "";
|
795
|
if ($pconfig['utype'] == "system") {
|
796
|
$ro = "readonly";
|
797
|
}
|
798
|
|
799
|
$section = new Form_Section('User Properties');
|
800
|
|
801
|
$section->addInput(new Form_StaticText(
|
802
|
'Defined by',
|
803
|
strtoupper($pconfig['utype'])
|
804
|
));
|
805
|
|
806
|
$form->addGlobal(new Form_Input(
|
807
|
'utype',
|
808
|
null,
|
809
|
'hidden',
|
810
|
$pconfig['utype']
|
811
|
));
|
812
|
|
813
|
$section->addInput(new Form_Checkbox(
|
814
|
'disabled',
|
815
|
'Disabled',
|
816
|
'This user cannot login',
|
817
|
$pconfig['disabled']
|
818
|
));
|
819
|
|
820
|
$section->addInput($input = new Form_Input(
|
821
|
'usernamefld',
|
822
|
'*Username',
|
823
|
'text',
|
824
|
$pconfig['usernamefld'],
|
825
|
['autocomplete' => 'new-password']
|
826
|
));
|
827
|
|
828
|
if ($ro) {
|
829
|
$input->setReadonly();
|
830
|
}
|
831
|
|
832
|
$form->addGlobal(new Form_Input(
|
833
|
'oldusername',
|
834
|
null,
|
835
|
'hidden',
|
836
|
$pconfig['usernamefld']
|
837
|
));
|
838
|
|
839
|
if ($act == "edit") {
|
840
|
$pwd_required = "";
|
841
|
} else {
|
842
|
$pwd_required = "*";
|
843
|
}
|
844
|
|
845
|
$group = new Form_Group($pwd_required . 'Password');
|
846
|
$group->add(new Form_Input(
|
847
|
'passwordfld1',
|
848
|
'Password',
|
849
|
'password',
|
850
|
null,
|
851
|
['autocomplete' => 'new-password']
|
852
|
))->setHelp('Enter a new password.' .
|
853
|
'%1$s%1$s' .
|
854
|
'Hints:%1$s' .
|
855
|
' %2$s', '<br/>', $password_extra_help);
|
856
|
$group->add(new Form_Input(
|
857
|
'passwordfld2',
|
858
|
'Confirm Password',
|
859
|
'password',
|
860
|
null,
|
861
|
['autocomplete' => 'new-password']
|
862
|
))->setHelp('Type the new password again for confirmation.');
|
863
|
|
864
|
$section->add($group);
|
865
|
|
866
|
$section->addInput($input = new Form_Input(
|
867
|
'descr',
|
868
|
'Full name',
|
869
|
'text',
|
870
|
$pconfig['descr']
|
871
|
))->setHelp('User\'s full name, for administrative information only');
|
872
|
|
873
|
if ($ro) {
|
874
|
$input->setDisabled();
|
875
|
}
|
876
|
|
877
|
$section->addInput(new Form_Input(
|
878
|
'expires',
|
879
|
'Expiration date',
|
880
|
'text',
|
881
|
$pconfig['expires']
|
882
|
))->setHelp('Leave blank if the account shouldn\'t expire, otherwise enter '.
|
883
|
'the expiration date as MM/DD/YYYY');
|
884
|
|
885
|
$section->addInput(new Form_Checkbox(
|
886
|
'customsettings',
|
887
|
'Custom Settings',
|
888
|
'Use individual customized GUI options and dashboard layout for this user.',
|
889
|
$pconfig['customsettings']
|
890
|
));
|
891
|
|
892
|
gen_user_settings_fields($section, $pconfig);
|
893
|
|
894
|
// ==== Group membership ==================================================
|
895
|
$group = new Form_Group('Group membership');
|
896
|
|
897
|
// Make a list of all the groups configured on the system, and a list of
|
898
|
// those which this user is a member of
|
899
|
$systemGroups = array();
|
900
|
$usersGroups = array();
|
901
|
|
902
|
$usergid = [$pconfig['usernamefld']];
|
903
|
|
904
|
foreach (config_get_path('system/group', []) as $Ggroup) {
|
905
|
if ($Ggroup['name'] != "all") {
|
906
|
if (($act == 'edit' || $input_errors) && $Ggroup['member'] && is_numericint($id) && in_array(config_get_path("system/user/{$id}/uid", []), $Ggroup['member'])) {
|
907
|
$usersGroups[ $Ggroup['name'] ] = $Ggroup['name']; // Add it to the user's list
|
908
|
} else {
|
909
|
$systemGroups[ $Ggroup['name'] ] = $Ggroup['name']; // Add it to the 'not a member of' list
|
910
|
}
|
911
|
}
|
912
|
}
|
913
|
|
914
|
$group->add(new Form_Select(
|
915
|
'sysgroups',
|
916
|
null,
|
917
|
array_combine((array)$pconfig['groups'], (array)$pconfig['groups']),
|
918
|
$systemGroups,
|
919
|
true
|
920
|
))->setHelp('Not member of');
|
921
|
|
922
|
$group->add(new Form_Select(
|
923
|
'groups',
|
924
|
null,
|
925
|
array_combine((array)$pconfig['groups'], (array)$pconfig['groups']),
|
926
|
$usersGroups,
|
927
|
true
|
928
|
))->setHelp('Member of');
|
929
|
|
930
|
$section->add($group);
|
931
|
|
932
|
$group = new Form_Group('');
|
933
|
|
934
|
$group->add(new Form_Button(
|
935
|
'movetoenabled',
|
936
|
'Move to "Member of" list',
|
937
|
null,
|
938
|
'fa-solid fa-angle-double-right'
|
939
|
))->setAttribute('type','button')->removeClass('btn-primary')->addClass('btn-info btn-sm');
|
940
|
|
941
|
$group->add(new Form_Button(
|
942
|
'movetodisabled',
|
943
|
'Move to "Not member of" list',
|
944
|
null,
|
945
|
'fa-solid fa-angle-double-left'
|
946
|
))->setAttribute('type','button')->removeClass('btn-primary')->addClass('btn-info btn-sm');
|
947
|
|
948
|
$group->setHelp('Hold down CTRL (PC)/COMMAND (Mac) key to select multiple items.');
|
949
|
$section->add($group);
|
950
|
|
951
|
// ==== Button for adding user certificate ================================
|
952
|
if ($act == 'new') {
|
953
|
if (count($nonPrvCas) > 0) {
|
954
|
$section->addInput(new Form_Checkbox(
|
955
|
'showcert',
|
956
|
'Certificate',
|
957
|
'Click to create a user certificate',
|
958
|
false
|
959
|
));
|
960
|
} else {
|
961
|
$section->addInput(new Form_StaticText(
|
962
|
'Certificate',
|
963
|
gettext('No private CAs found. A private CA is required to create a new user certificate. ' .
|
964
|
'Save the user first to import an external certificate.')
|
965
|
));
|
966
|
}
|
967
|
}
|
968
|
|
969
|
$form->add($section);
|
970
|
|
971
|
// ==== Effective privileges section ======================================
|
972
|
if (isset($pconfig['uid'])) {
|
973
|
// We are going to build an HTML table and add it to an Input_StaticText. It may be ugly, but it
|
974
|
// is the best way to make the display we need.
|
975
|
|
976
|
$section = new Form_Section('Effective Privileges');
|
977
|
|
978
|
$section->addInput(new Form_StaticText(
|
979
|
null,
|
980
|
build_priv_table()
|
981
|
));
|
982
|
|
983
|
$form->add($section);
|
984
|
|
985
|
// ==== Certificate table section =====================================
|
986
|
$section = new Form_Section('User Certificates');
|
987
|
|
988
|
$section->addInput(new Form_StaticText(
|
989
|
null,
|
990
|
build_cert_table()
|
991
|
));
|
992
|
|
993
|
$form->add($section);
|
994
|
}
|
995
|
|
996
|
// ==== Add user certificate for a new user
|
997
|
if (count(config_get_path('ca', [])) > 0) {
|
998
|
$section = new Form_Section('Create Certificate for User');
|
999
|
$section->addClass('cert-options');
|
1000
|
|
1001
|
if (!empty($nonPrvCas)) {
|
1002
|
$section->addInput(new Form_Input(
|
1003
|
'name',
|
1004
|
'Descriptive name',
|
1005
|
'text',
|
1006
|
$pconfig['name']
|
1007
|
));
|
1008
|
|
1009
|
$section->addInput(new Form_Select(
|
1010
|
'caref',
|
1011
|
'Certificate authority',
|
1012
|
null,
|
1013
|
$nonPrvCas
|
1014
|
));
|
1015
|
|
1016
|
$section->addInput(new Form_Select(
|
1017
|
'keytype',
|
1018
|
'*Key type',
|
1019
|
$pconfig['keytype'],
|
1020
|
array_combine($cert_keytypes, $cert_keytypes)
|
1021
|
));
|
1022
|
|
1023
|
$group = new Form_Group($i == 0 ? '*Key length':'');
|
1024
|
$group->addClass('rsakeys');
|
1025
|
$group->add(new Form_Select(
|
1026
|
'keylen',
|
1027
|
null,
|
1028
|
$pconfig['keylen'] ? $pconfig['keylen'] : '2048',
|
1029
|
array_combine($cert_keylens, $cert_keylens)
|
1030
|
))->setHelp('The length to use when generating a new RSA key, in bits. %1$s' .
|
1031
|
'The Key Length should not be lower than 2048 or some platforms ' .
|
1032
|
'may consider the certificate invalid.', '<br/>');
|
1033
|
$section->add($group);
|
1034
|
|
1035
|
$group = new Form_Group($i == 0 ? '*Elliptic Curve Name':'');
|
1036
|
$group->addClass('ecnames');
|
1037
|
$group->add(new Form_Select(
|
1038
|
'ecname',
|
1039
|
null,
|
1040
|
$pconfig['ecname'] ? $pconfig['ecname'] : 'prime256v1',
|
1041
|
$openssl_ecnames
|
1042
|
))->setHelp('Curves may not be compatible with all uses. Known compatible curve uses are denoted in brackets.');
|
1043
|
$section->add($group);
|
1044
|
|
1045
|
$section->addInput(new Form_Select(
|
1046
|
'digest_alg',
|
1047
|
'*Digest Algorithm',
|
1048
|
$pconfig['digest_alg'] ? $pconfig['digest_alg'] : 'sha256',
|
1049
|
array_combine($openssl_digest_algs, $openssl_digest_algs)
|
1050
|
))->setHelp('The digest method used when the certificate is signed. %1$s' .
|
1051
|
'The best practice is to use an algorithm stronger than SHA1. '.
|
1052
|
'Some platforms may consider weaker digest algorithms invalid', '<br/>');
|
1053
|
|
1054
|
$section->addInput(new Form_Input(
|
1055
|
'lifetime',
|
1056
|
'Lifetime',
|
1057
|
'number',
|
1058
|
$pconfig['lifetime']
|
1059
|
));
|
1060
|
}
|
1061
|
|
1062
|
$form->add($section);
|
1063
|
}
|
1064
|
|
1065
|
endif;
|
1066
|
// ==== Paste a key for the new user
|
1067
|
$section = new Form_Section('Keys');
|
1068
|
|
1069
|
$section->addInput(new Form_Checkbox(
|
1070
|
'showkey',
|
1071
|
'Authorized keys',
|
1072
|
'Click to paste an authorized key',
|
1073
|
false
|
1074
|
));
|
1075
|
|
1076
|
$section->addInput(new Form_Textarea(
|
1077
|
'authorizedkeys',
|
1078
|
'Authorized SSH Keys',
|
1079
|
$pconfig['authorizedkeys']
|
1080
|
))->setHelp('Enter authorized SSH keys for this user');
|
1081
|
|
1082
|
$section->addInput(new Form_Input(
|
1083
|
'ipsecpsk',
|
1084
|
'IPsec Pre-Shared Key',
|
1085
|
'text',
|
1086
|
$pconfig['ipsecpsk']
|
1087
|
));
|
1088
|
|
1089
|
$form->add($section);
|
1090
|
|
1091
|
$section = new Form_Section('Shell Behavior');
|
1092
|
|
1093
|
$section->addInput(new Form_Checkbox(
|
1094
|
'keephistory',
|
1095
|
'Keep Command History',
|
1096
|
'Keep shell command history between login sessions',
|
1097
|
$pconfig['keephistory']
|
1098
|
))->setHelp('If this user has shell access, this option preserves the last 1000 unique commands entered at a shell prompt between login sessions. ' .
|
1099
|
'The user can access history using the up and down arrows at an SSH or console shell prompt ' .
|
1100
|
'and search the history by typing a partial command and then using the up or down arrows.');
|
1101
|
|
1102
|
$form->add($section);
|
1103
|
|
1104
|
print $form;
|
1105
|
|
1106
|
$csswarning = sprintf(gettext("%sUser-created themes are unsupported, use at your own risk."), "<br />");
|
1107
|
?>
|
1108
|
<script type="text/javascript">
|
1109
|
//<![CDATA[
|
1110
|
events.push(function() {
|
1111
|
|
1112
|
function setcustomoptions() {
|
1113
|
var adv = $('#customsettings').prop('checked');
|
1114
|
|
1115
|
hideInput('webguicss', !adv);
|
1116
|
hideInput('webguifixedmenu', !adv);
|
1117
|
hideInput('webguihostnamemenu', !adv);
|
1118
|
hideInput('dashboardcolumns', !adv);
|
1119
|
hideCheckbox('interfacessort', !adv);
|
1120
|
hideCheckbox('dashboardavailablewidgetspanel', !adv);
|
1121
|
hideCheckbox('systemlogsfilterpanel', !adv);
|
1122
|
hideCheckbox('systemlogsmanagelogpanel', !adv);
|
1123
|
hideCheckbox('statusmonitoringsettingspanel', !adv);
|
1124
|
hideCheckbox('webguileftcolumnhyper', !adv);
|
1125
|
hideCheckbox('disablealiaspopupdetail', !adv);
|
1126
|
hideCheckbox('pagenamefirst', !adv);
|
1127
|
}
|
1128
|
|
1129
|
// Handle displaying a warning message if a user-created theme is selected.
|
1130
|
function setThemeWarning() {
|
1131
|
if ($('#webguicss').val().startsWith("pfSense")) {
|
1132
|
$('#csstxt').html("").addClass("text-default");
|
1133
|
} else {
|
1134
|
$('#csstxt').html("<?=$csswarning?>").addClass("text-danger");
|
1135
|
}
|
1136
|
}
|
1137
|
|
1138
|
function change_keytype() {
|
1139
|
hideClass('rsakeys', ($('#keytype').val() != 'RSA'));
|
1140
|
hideClass('ecnames', ($('#keytype').val() != 'ECDSA'));
|
1141
|
}
|
1142
|
|
1143
|
$('#webguicss').change(function() {
|
1144
|
setThemeWarning();
|
1145
|
});
|
1146
|
|
1147
|
setThemeWarning();
|
1148
|
|
1149
|
// On click . .
|
1150
|
$('#customsettings').click(function () {
|
1151
|
setcustomoptions();
|
1152
|
});
|
1153
|
|
1154
|
$("#movetodisabled").click(function() {
|
1155
|
moveOptions($('[name="groups[]"] option'), $('[name="sysgroups[]"]'));
|
1156
|
});
|
1157
|
|
1158
|
$("#movetoenabled").click(function() {
|
1159
|
moveOptions($('[name="sysgroups[]"] option'), $('[name="groups[]"]'));
|
1160
|
});
|
1161
|
|
1162
|
$("#showcert").click(function() {
|
1163
|
hideClass('cert-options', !this.checked);
|
1164
|
});
|
1165
|
|
1166
|
$("#showkey").click(function() {
|
1167
|
hideInput('authorizedkeys', false);
|
1168
|
hideCheckbox('showkey', true);
|
1169
|
});
|
1170
|
|
1171
|
$('[id^=delcert]').click(function(event) {
|
1172
|
if (confirm(event.target.title)) {
|
1173
|
$('#certid').val(event.target.id.match(/\d+$/)[0]);
|
1174
|
$('#userid').val('<?=$id;?>');
|
1175
|
$('#act').val('delcert');
|
1176
|
$('form').submit();
|
1177
|
}
|
1178
|
});
|
1179
|
|
1180
|
$('[id^=delprivid]').click(function(event) {
|
1181
|
if (confirm(event.target.title)) {
|
1182
|
$('#privid').val(event.target.id.match(/\d+$/)[0]);
|
1183
|
$('#userid').val('<?=$id;?>');
|
1184
|
$('#act').val('delprivid');
|
1185
|
$('form').submit();
|
1186
|
}
|
1187
|
});
|
1188
|
|
1189
|
$('#expires').datepicker();
|
1190
|
|
1191
|
$('#keytype').change(function () {
|
1192
|
change_keytype();
|
1193
|
});
|
1194
|
|
1195
|
// ---------- On initial page load ------------------------------------------------------------
|
1196
|
|
1197
|
hideClass('cert-options', true);
|
1198
|
//hideInput('authorizedkeys', true);
|
1199
|
hideCheckbox('showkey', true);
|
1200
|
setcustomoptions();
|
1201
|
change_keytype();
|
1202
|
|
1203
|
// On submit mark all the user's groups as "selected"
|
1204
|
$('form').submit(function() {
|
1205
|
AllServers($('[name="groups[]"] option'), true);
|
1206
|
});
|
1207
|
|
1208
|
});
|
1209
|
//]]>
|
1210
|
</script>
|
1211
|
<?php
|
1212
|
include('foot.inc');
|
1213
|
?>
|