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