1
|
<?php
|
2
|
/*
|
3
|
system_authservers.php
|
4
|
*/
|
5
|
/* ====================================================================
|
6
|
* Copyright (c) 2004-2015 Electric Sheep Fencing, LLC. All rights reserved.
|
7
|
* Copyright (c) 2008 Shrew Soft Inc.
|
8
|
*
|
9
|
* Redistribution and use in source and binary forms, with or without modification,
|
10
|
* are permitted provided that the following conditions are met:
|
11
|
*
|
12
|
* 1. Redistributions of source code must retain the above copyright notice,
|
13
|
* this list of conditions and the following disclaimer.
|
14
|
*
|
15
|
* 2. Redistributions in binary form must reproduce the above copyright
|
16
|
* notice, this list of conditions and the following disclaimer in
|
17
|
* the documentation and/or other materials provided with the
|
18
|
* distribution.
|
19
|
*
|
20
|
* 3. All advertising materials mentioning features or use of this software
|
21
|
* must display the following acknowledgment:
|
22
|
* "This product includes software developed by the pfSense Project
|
23
|
* for use in the pfSense software distribution. (http://www.pfsense.org/).
|
24
|
*
|
25
|
* 4. The names "pfSense" and "pfSense Project" must not be used to
|
26
|
* endorse or promote products derived from this software without
|
27
|
* prior written permission. For written permission, please contact
|
28
|
* coreteam@pfsense.org.
|
29
|
*
|
30
|
* 5. Products derived from this software may not be called "pfSense"
|
31
|
* nor may "pfSense" appear in their names without prior written
|
32
|
* permission of the Electric Sheep Fencing, LLC.
|
33
|
*
|
34
|
* 6. Redistributions of any form whatsoever must retain the following
|
35
|
* acknowledgment:
|
36
|
*
|
37
|
* "This product includes software developed by the pfSense Project
|
38
|
* for use in the pfSense software distribution (http://www.pfsense.org/).
|
39
|
*
|
40
|
* THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
|
41
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
42
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
43
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
|
44
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
45
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
46
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
47
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
48
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
49
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
50
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
51
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
52
|
*
|
53
|
* ====================================================================
|
54
|
*
|
55
|
*/
|
56
|
|
57
|
##|+PRIV
|
58
|
##|*IDENT=page-system-authservers
|
59
|
##|*NAME=System: Authentication Servers
|
60
|
##|*DESCR=Allow access to the 'System: Authentication Servers' page.
|
61
|
##|*MATCH=system_authservers.php*
|
62
|
##|-PRIV
|
63
|
|
64
|
require("guiconfig.inc");
|
65
|
require_once("auth.inc");
|
66
|
|
67
|
if (is_numericint($_GET['id'])) {
|
68
|
$id = $_GET['id'];
|
69
|
}
|
70
|
if (isset($_POST['id']) && is_numericint($_POST['id'])) {
|
71
|
$id = $_POST['id'];
|
72
|
}
|
73
|
|
74
|
if (!is_array($config['system']['authserver'])) {
|
75
|
$config['system']['authserver'] = array();
|
76
|
}
|
77
|
|
78
|
$a_servers = auth_get_authserver_list();
|
79
|
foreach ($a_servers as $servers) {
|
80
|
$a_server[] = $servers;
|
81
|
}
|
82
|
|
83
|
if (!is_array($config['ca'])) {
|
84
|
$config['ca'] = array();
|
85
|
}
|
86
|
$a_ca =& $config['ca'];
|
87
|
|
88
|
$act = $_GET['act'];
|
89
|
if ($_POST['act']) {
|
90
|
$act = $_POST['act'];
|
91
|
}
|
92
|
|
93
|
if ($act == "del") {
|
94
|
|
95
|
if (!$a_server[$_GET['id']]) {
|
96
|
pfSenseHeader("system_authservers.php");
|
97
|
exit;
|
98
|
}
|
99
|
|
100
|
/* Remove server from main list. */
|
101
|
$serverdeleted = $a_server[$_GET['id']]['name'];
|
102
|
foreach ($config['system']['authserver'] as $k => $as) {
|
103
|
if ($config['system']['authserver'][$k]['name'] == $serverdeleted) {
|
104
|
unset($config['system']['authserver'][$k]);
|
105
|
}
|
106
|
}
|
107
|
|
108
|
/* Remove server from temp list used later on this page. */
|
109
|
unset($a_server[$_GET['id']]);
|
110
|
|
111
|
$savemsg = sprintf(gettext("Authentication Server %s deleted"), htmlspecialchars($serverdeleted));
|
112
|
write_config($savemsg);
|
113
|
}
|
114
|
|
115
|
if ($act == "edit") {
|
116
|
if (isset($id) && $a_server[$id]) {
|
117
|
|
118
|
$pconfig['type'] = $a_server[$id]['type'];
|
119
|
$pconfig['name'] = $a_server[$id]['name'];
|
120
|
|
121
|
if ($pconfig['type'] == "ldap") {
|
122
|
$pconfig['ldap_caref'] = $a_server[$id]['ldap_caref'];
|
123
|
$pconfig['ldap_host'] = $a_server[$id]['host'];
|
124
|
$pconfig['ldap_port'] = $a_server[$id]['ldap_port'];
|
125
|
$pconfig['ldap_timeout'] = $a_server[$id]['ldap_timeout'];
|
126
|
$pconfig['ldap_urltype'] = $a_server[$id]['ldap_urltype'];
|
127
|
$pconfig['ldap_protver'] = $a_server[$id]['ldap_protver'];
|
128
|
$pconfig['ldap_scope'] = $a_server[$id]['ldap_scope'];
|
129
|
$pconfig['ldap_basedn'] = $a_server[$id]['ldap_basedn'];
|
130
|
$pconfig['ldap_authcn'] = $a_server[$id]['ldap_authcn'];
|
131
|
$pconfig['ldap_extended_enabled'] = $a_server[$id]['ldap_extended_enabled'];
|
132
|
$pconfig['ldap_extended_query'] = $a_server[$id]['ldap_extended_query'];
|
133
|
$pconfig['ldap_binddn'] = $a_server[$id]['ldap_binddn'];
|
134
|
$pconfig['ldap_bindpw'] = $a_server[$id]['ldap_bindpw'];
|
135
|
$pconfig['ldap_attr_user'] = $a_server[$id]['ldap_attr_user'];
|
136
|
$pconfig['ldap_attr_group'] = $a_server[$id]['ldap_attr_group'];
|
137
|
$pconfig['ldap_attr_member'] = $a_server[$id]['ldap_attr_member'];
|
138
|
$pconfig['ldap_attr_groupobj'] = $a_server[$id]['ldap_attr_groupobj'];
|
139
|
$pconfig['ldap_utf8'] = isset($a_server[$id]['ldap_utf8']);
|
140
|
$pconfig['ldap_nostrip_at'] = isset($a_server[$id]['ldap_nostrip_at']);
|
141
|
$pconfig['ldap_rfc2307'] = isset($a_server[$id]['ldap_rfc2307']);
|
142
|
|
143
|
if (!$pconfig['ldap_binddn'] || !$pconfig['ldap_bindpw']) {
|
144
|
$pconfig['ldap_anon'] = true;
|
145
|
}
|
146
|
}
|
147
|
|
148
|
if ($pconfig['type'] == "radius") {
|
149
|
$pconfig['radius_host'] = $a_server[$id]['host'];
|
150
|
$pconfig['radius_auth_port'] = $a_server[$id]['radius_auth_port'];
|
151
|
$pconfig['radius_acct_port'] = $a_server[$id]['radius_acct_port'];
|
152
|
$pconfig['radius_secret'] = $a_server[$id]['radius_secret'];
|
153
|
$pconfig['radius_timeout'] = $a_server[$id]['radius_timeout'];
|
154
|
|
155
|
if ($pconfig['radius_auth_port'] &&
|
156
|
$pconfig['radius_acct_port']) {
|
157
|
$pconfig['radius_srvcs'] = "both";
|
158
|
}
|
159
|
|
160
|
if ($pconfig['radius_auth_port'] &&
|
161
|
!$pconfig['radius_acct_port']) {
|
162
|
$pconfig['radius_srvcs'] = "auth";
|
163
|
$pconfig['radius_acct_port'] = 1813;
|
164
|
}
|
165
|
|
166
|
if (!$pconfig['radius_auth_port'] &&
|
167
|
$pconfig['radius_acct_port']) {
|
168
|
$pconfig['radius_srvcs'] = "acct";
|
169
|
$pconfig['radius_auth_port'] = 1812;
|
170
|
}
|
171
|
|
172
|
}
|
173
|
}
|
174
|
}
|
175
|
|
176
|
if ($act == "new") {
|
177
|
$pconfig['ldap_protver'] = 3;
|
178
|
$pconfig['ldap_anon'] = true;
|
179
|
$pconfig['radius_srvcs'] = "both";
|
180
|
$pconfig['radius_auth_port'] = "1812";
|
181
|
$pconfig['radius_acct_port'] = "1813";
|
182
|
}
|
183
|
|
184
|
if ($_POST) {
|
185
|
unset($input_errors);
|
186
|
$pconfig = $_POST;
|
187
|
|
188
|
/* input validation */
|
189
|
|
190
|
if ($pconfig['type'] == "ldap") {
|
191
|
$reqdfields = explode(" ",
|
192
|
"name type ldap_host ldap_port " .
|
193
|
"ldap_urltype ldap_protver ldap_scope " .
|
194
|
"ldap_attr_user ldap_attr_group ldap_attr_member ldapauthcontainers");
|
195
|
|
196
|
$reqdfieldsn = array(
|
197
|
gettext("Descriptive name"),
|
198
|
gettext("Type"),
|
199
|
gettext("Hostname or IP"),
|
200
|
gettext("Port value"),
|
201
|
gettext("Transport"),
|
202
|
gettext("Protocol version"),
|
203
|
gettext("Search level"),
|
204
|
gettext("User naming Attribute"),
|
205
|
gettext("Group naming Attribute"),
|
206
|
gettext("Group member attribute"),
|
207
|
gettext("Authentication container"));
|
208
|
|
209
|
if (!$pconfig['ldap_anon']) {
|
210
|
$reqdfields[] = "ldap_binddn";
|
211
|
$reqdfields[] = "ldap_bindpw";
|
212
|
$reqdfieldsn[] = gettext("Bind user DN");
|
213
|
$reqdfieldsn[] = gettext("Bind Password");
|
214
|
}
|
215
|
}
|
216
|
|
217
|
if ($pconfig['type'] == "radius") {
|
218
|
$reqdfields = explode(" ", "name type radius_host radius_srvcs");
|
219
|
$reqdfieldsn = array(
|
220
|
gettext("Descriptive name"),
|
221
|
gettext("Type"),
|
222
|
gettext("Hostname or IP"),
|
223
|
gettext("Services"));
|
224
|
|
225
|
if ($pconfig['radisu_srvcs'] == "both" ||
|
226
|
$pconfig['radisu_srvcs'] == "auth") {
|
227
|
$reqdfields[] = "radius_auth_port";
|
228
|
$reqdfieldsn[] = gettext("Authentication port");
|
229
|
}
|
230
|
|
231
|
if ($pconfig['radisu_srvcs'] == "both" ||
|
232
|
$pconfig['radisu_srvcs'] == "acct") {
|
233
|
$reqdfields[] = "radius_acct_port";
|
234
|
$reqdfieldsn[] = gettext("Accounting port");
|
235
|
}
|
236
|
|
237
|
if (!isset($id)) {
|
238
|
$reqdfields[] = "radius_secret";
|
239
|
$reqdfieldsn[] = gettext("Shared Secret");
|
240
|
}
|
241
|
}
|
242
|
|
243
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
|
244
|
|
245
|
if (preg_match("/[^a-zA-Z0-9\.\-_]/", $_POST['host'])) {
|
246
|
$input_errors[] = gettext("The host name contains invalid characters.");
|
247
|
}
|
248
|
|
249
|
if (auth_get_authserver($pconfig['name']) && !isset($id)) {
|
250
|
$input_errors[] = gettext("An authentication server with the same name already exists.");
|
251
|
}
|
252
|
|
253
|
if (($pconfig['type'] == "ldap") || ($pconfig['type'] == "radius")) {
|
254
|
$to_field = "{$pconfig['type']}_timeout";
|
255
|
if (isset($_POST[$to_field]) && !empty($_POST[$to_field]) && (!is_numeric($_POST[$to_field]) || (is_numeric($_POST[$to_field]) && ($_POST[$to_field] <= 0)))) {
|
256
|
$input_errors[] = sprintf(gettext("%s Timeout value must be numeric and positive."), strtoupper($pconfig['type']));
|
257
|
}
|
258
|
}
|
259
|
|
260
|
/* if this is an AJAX caller then handle via JSON */
|
261
|
if (isAjax() && is_array($input_errors)) {
|
262
|
input_errors2Ajax($input_errors);
|
263
|
exit;
|
264
|
}
|
265
|
|
266
|
if (!$input_errors) {
|
267
|
$server = array();
|
268
|
$server['refid'] = uniqid();
|
269
|
if (isset($id) && $a_server[$id]) {
|
270
|
$server = $a_server[$id];
|
271
|
}
|
272
|
|
273
|
$server['type'] = $pconfig['type'];
|
274
|
$server['name'] = $pconfig['name'];
|
275
|
|
276
|
if ($server['type'] == "ldap") {
|
277
|
|
278
|
if (!empty($pconfig['ldap_caref'])) {
|
279
|
$server['ldap_caref'] = $pconfig['ldap_caref'];
|
280
|
}
|
281
|
$server['host'] = $pconfig['ldap_host'];
|
282
|
$server['ldap_port'] = $pconfig['ldap_port'];
|
283
|
$server['ldap_urltype'] = $pconfig['ldap_urltype'];
|
284
|
$server['ldap_protver'] = $pconfig['ldap_protver'];
|
285
|
$server['ldap_scope'] = $pconfig['ldap_scope'];
|
286
|
$server['ldap_basedn'] = $pconfig['ldap_basedn'];
|
287
|
$server['ldap_authcn'] = $pconfig['ldapauthcontainers'];
|
288
|
$server['ldap_extended_enabled'] = $pconfig['ldap_extended_enabled'];
|
289
|
$server['ldap_extended_query'] = $pconfig['ldap_extended_query'];
|
290
|
$server['ldap_attr_user'] = $pconfig['ldap_attr_user'];
|
291
|
$server['ldap_attr_group'] = $pconfig['ldap_attr_group'];
|
292
|
$server['ldap_attr_member'] = $pconfig['ldap_attr_member'];
|
293
|
|
294
|
$server['ldap_attr_groupobj'] = empty($pconfig['ldap_attr_groupobj']) ? "posixGroup" : $pconfig['ldap_attr_groupobj'];
|
295
|
|
296
|
if ($pconfig['ldap_utf8'] == "yes") {
|
297
|
$server['ldap_utf8'] = true;
|
298
|
} else {
|
299
|
unset($server['ldap_utf8']);
|
300
|
}
|
301
|
if ($pconfig['ldap_nostrip_at'] == "yes") {
|
302
|
$server['ldap_nostrip_at'] = true;
|
303
|
} else {
|
304
|
unset($server['ldap_nostrip_at']);
|
305
|
}
|
306
|
if ($pconfig['ldap_rfc2307'] == "yes") {
|
307
|
$server['ldap_rfc2307'] = true;
|
308
|
} else {
|
309
|
unset($server['ldap_rfc2307']);
|
310
|
}
|
311
|
|
312
|
|
313
|
if (!$pconfig['ldap_anon']) {
|
314
|
$server['ldap_binddn'] = $pconfig['ldap_binddn'];
|
315
|
$server['ldap_bindpw'] = $pconfig['ldap_bindpw'];
|
316
|
} else {
|
317
|
unset($server['ldap_binddn']);
|
318
|
unset($server['ldap_bindpw']);
|
319
|
}
|
320
|
|
321
|
if ($pconfig['ldap_timeout']) {
|
322
|
$server['ldap_timeout'] = $pconfig['ldap_timeout'];
|
323
|
} else {
|
324
|
$server['ldap_timeout'] = 25;
|
325
|
}
|
326
|
}
|
327
|
|
328
|
if ($server['type'] == "radius") {
|
329
|
|
330
|
$server['host'] = $pconfig['radius_host'];
|
331
|
|
332
|
if ($pconfig['radius_secret']) {
|
333
|
$server['radius_secret'] = $pconfig['radius_secret'];
|
334
|
}
|
335
|
|
336
|
if ($pconfig['radius_timeout']) {
|
337
|
$server['radius_timeout'] = $pconfig['radius_timeout'];
|
338
|
} else {
|
339
|
$server['radius_timeout'] = 5;
|
340
|
}
|
341
|
|
342
|
if ($pconfig['radius_srvcs'] == "both") {
|
343
|
$server['radius_auth_port'] = $pconfig['radius_auth_port'];
|
344
|
$server['radius_acct_port'] = $pconfig['radius_acct_port'];
|
345
|
}
|
346
|
|
347
|
if ($pconfig['radius_srvcs'] == "auth") {
|
348
|
$server['radius_auth_port'] = $pconfig['radius_auth_port'];
|
349
|
unset($server['radius_acct_port']);
|
350
|
}
|
351
|
|
352
|
if ($pconfig['radius_srvcs'] == "acct") {
|
353
|
$server['radius_acct_port'] = $pconfig['radius_acct_port'];
|
354
|
unset($server['radius_auth_port']);
|
355
|
}
|
356
|
}
|
357
|
|
358
|
if (isset($id) && $config['system']['authserver'][$id]) {
|
359
|
$config['system']['authserver'][$id] = $server;
|
360
|
} else {
|
361
|
$config['system']['authserver'][] = $server;
|
362
|
}
|
363
|
|
364
|
write_config();
|
365
|
|
366
|
pfSenseHeader("system_authservers.php");
|
367
|
}
|
368
|
}
|
369
|
|
370
|
// On error, restore the form contents so the user doesn't have to re-enter too much
|
371
|
if($_POST && $input_errors) {
|
372
|
$pconfig = $_POST;
|
373
|
$pconfig['ldap_authcn'] = $_POST['ldapauthcontainers'];
|
374
|
$pconfig['ldap_template'] = $_POST['ldap_tmpltype'];
|
375
|
}
|
376
|
|
377
|
$pgtitle = array(gettext("System"), gettext("User Manager"), gettext("Authentication Servers"));
|
378
|
|
379
|
if ($act == "new" || $act == "edit" || $input_errors) {
|
380
|
$pgtitle[] = gettext('Edit');
|
381
|
}
|
382
|
$shortcut_section = "authentication";
|
383
|
include("head.inc");
|
384
|
|
385
|
if ($input_errors) {
|
386
|
print_input_errors($input_errors);
|
387
|
}
|
388
|
|
389
|
if ($savemsg) {
|
390
|
print_info_box($savemsg, 'success');
|
391
|
}
|
392
|
|
393
|
$tab_array = array();
|
394
|
$tab_array[] = array(gettext("Users"), false, "system_usermanager.php");
|
395
|
$tab_array[] = array(gettext("Groups"), false, "system_groupmanager.php");
|
396
|
$tab_array[] = array(gettext("Settings"), false, "system_usermanager_settings.php");
|
397
|
$tab_array[] = array(gettext("Authentication Servers"), true, "system_authservers.php");
|
398
|
display_top_tabs($tab_array);
|
399
|
|
400
|
if (!($act == "new" || $act == "edit" || $input_errors)) {
|
401
|
?>
|
402
|
<div class="panel panel-default">
|
403
|
<div class="panel-heading"><h2 class="panel-title"><?=gettext('Authentication Servers')?></h2></div>
|
404
|
<div class="panel-body">
|
405
|
<div class="table-responsive">
|
406
|
<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
|
407
|
<thead>
|
408
|
<tr>
|
409
|
<th><?=gettext("Server Name")?></th>
|
410
|
<th><?=gettext("Type")?></th>
|
411
|
<th><?=gettext("Host Name")?></th>
|
412
|
<th><?=gettext("Actions")?></th>
|
413
|
</tr>
|
414
|
</thead>
|
415
|
<tbody>
|
416
|
<?php foreach($a_server as $i => $server): ?>
|
417
|
<tr>
|
418
|
<td><?=htmlspecialchars($server['name'])?></td>
|
419
|
<td><?=htmlspecialchars($auth_server_types[$server['type']])?></td>
|
420
|
<td><?=htmlspecialchars($server['host'])?></td>
|
421
|
<td>
|
422
|
<?php if ($i < (count($a_server) - 1)): ?>
|
423
|
<a class="fa fa-pencil" title="<?=gettext("Edit server"); ?>" href="system_authservers.php?act=edit&id=<?=$i?>"></a>
|
424
|
<a class="fa fa-trash" title="<?=gettext("Delete server")?>" href="system_authservers.php?act=del&id=<?=$i?>"></a>
|
425
|
<?php endif?>
|
426
|
</td>
|
427
|
</tr>
|
428
|
<?php endforeach; ?>
|
429
|
</tbody>
|
430
|
</table>
|
431
|
</div>
|
432
|
</div>
|
433
|
</div>
|
434
|
|
435
|
<nav class="action-buttons">
|
436
|
<a href="?act=new" class="btn btn-success btn-sm">
|
437
|
<i class="fa fa-plus icon-embed-btn"></i>
|
438
|
<?=gettext("Add")?>
|
439
|
</a>
|
440
|
</nav>
|
441
|
<?php
|
442
|
include("foot.inc");
|
443
|
exit;
|
444
|
}
|
445
|
|
446
|
$form = new Form;
|
447
|
$form->setAction('system_authservers.php?act=edit');
|
448
|
|
449
|
$form->addGlobal(new Form_Input(
|
450
|
'userid',
|
451
|
null,
|
452
|
'hidden',
|
453
|
$id
|
454
|
));
|
455
|
|
456
|
$section = new Form_Section('Server Settings');
|
457
|
|
458
|
$section->addInput($input = new Form_Input(
|
459
|
'name',
|
460
|
'Descriptive name',
|
461
|
'text',
|
462
|
$pconfig['name']
|
463
|
));
|
464
|
|
465
|
$section->addInput($input = new Form_Select(
|
466
|
'type',
|
467
|
'Type',
|
468
|
$pconfig['type'],
|
469
|
$auth_server_types
|
470
|
))->toggles();
|
471
|
|
472
|
$form->add($section);
|
473
|
|
474
|
// ==== LDAP settings =========================================================
|
475
|
$section = new Form_Section('LDAP Server Settings');
|
476
|
$section->addClass('toggle-ldap collapse');
|
477
|
|
478
|
if (!isset($pconfig['type']) || $pconfig['type'] == 'ldap')
|
479
|
$section->addClass('in');
|
480
|
|
481
|
$section->addInput(new Form_Input(
|
482
|
'ldap_host',
|
483
|
'Hostname or IP address',
|
484
|
'text',
|
485
|
$pconfig['ldap_host']
|
486
|
))->setHelp('NOTE: When using SSL, this hostname MUST match the Common Name '.
|
487
|
'(CN) of the LDAP server\'s SSL Certificate.');
|
488
|
|
489
|
$section->addInput(new Form_Input(
|
490
|
'ldap_port',
|
491
|
'Port value',
|
492
|
'number',
|
493
|
$pconfig['ldap_port']
|
494
|
));
|
495
|
|
496
|
$section->addInput(new Form_Select(
|
497
|
'ldap_urltype',
|
498
|
'Transport',
|
499
|
$pconfig['ldap_urltype'],
|
500
|
array_combine(array_keys($ldap_urltypes), array_keys($ldap_urltypes))
|
501
|
));
|
502
|
|
503
|
if (empty($a_ca))
|
504
|
{
|
505
|
$section->addInput(new Form_StaticText(
|
506
|
'Peer Certificate Authority',
|
507
|
'No Certificate Authorities defined.<br/>Create one under <a href="system_camanager.php">System > Cert. Manager</a>.'
|
508
|
));
|
509
|
}
|
510
|
else
|
511
|
{
|
512
|
$ldapCaRef = [];
|
513
|
foreach ($a_ca as $ca)
|
514
|
$ldapCaRef[ $ca['refid'] ] = $ca['descr'];
|
515
|
|
516
|
$section->addInput(new Form_Select(
|
517
|
'ldap_caref',
|
518
|
'Peer Certificate Authority',
|
519
|
$pconfig['ldap_caref'],
|
520
|
$ldapCaRef
|
521
|
))->setHelp('This option is used if \'SSL Encrypted\' option is choosen. '.
|
522
|
'It must match with the CA in the AD otherwise problems will arise.');
|
523
|
}
|
524
|
|
525
|
$section->addInput(new Form_Select(
|
526
|
'ldap_protver',
|
527
|
'Protocol version',
|
528
|
$pconfig['ldap_protver'],
|
529
|
array_combine($ldap_protvers, $ldap_protvers)
|
530
|
));
|
531
|
|
532
|
$section->addInput(new Form_Input(
|
533
|
'ldap_timeout',
|
534
|
'Server Timeout',
|
535
|
'number',
|
536
|
$pconfig['ldap_timeout'],
|
537
|
['placeholder' => 25]
|
538
|
))->setHelp('Timeout for LDAP operations (seconds)');
|
539
|
|
540
|
$group = new Form_Group('Search scope');
|
541
|
|
542
|
$SSF = new Form_Select(
|
543
|
'ldap_scope',
|
544
|
'Level',
|
545
|
$pconfig['ldap_scope'],
|
546
|
$ldap_scopes
|
547
|
);
|
548
|
|
549
|
$SSB = new Form_Input(
|
550
|
'ldap_basedn',
|
551
|
'Base DN',
|
552
|
'text',
|
553
|
$pconfig['ldap_basedn']
|
554
|
);
|
555
|
|
556
|
|
557
|
$section->addInput(new Form_StaticText(
|
558
|
'Search scope',
|
559
|
'Level ' . $SSF . '<br />' . 'Base DN' . $SSB
|
560
|
));
|
561
|
|
562
|
$group = new Form_Group('Authentication containers');
|
563
|
$group->add(new Form_Input(
|
564
|
'ldapauthcontainers',
|
565
|
'Containers',
|
566
|
'text',
|
567
|
$pconfig['ldap_authcn']
|
568
|
))->setHelp('Note: Semi-Colon separated. This will be prepended to the search '.
|
569
|
'base dn above or you can specify full container path containing a dc= '.
|
570
|
'component.<br/>Example: CN=Users;DC=example,DC=com or OU=Staff;OU=Freelancers');
|
571
|
|
572
|
$group->add(new Form_Button(
|
573
|
'Select',
|
574
|
'Select a container'
|
575
|
))->removeClass('btn-primary')->addClass('btn-default');
|
576
|
|
577
|
$section->add($group);
|
578
|
|
579
|
$section->addInput(new Form_Checkbox(
|
580
|
'ldap_extended_enabled',
|
581
|
'Extended query',
|
582
|
'Enable extended query',
|
583
|
$pconfig['ldap_extended_enabled']
|
584
|
));
|
585
|
|
586
|
$group = new Form_Group('Query');
|
587
|
$group->addClass('extended');
|
588
|
|
589
|
$group->add(new Form_Input(
|
590
|
'ldap_extended_query',
|
591
|
'Query',
|
592
|
'text',
|
593
|
$pconfig['ldap_extended_query']
|
594
|
))->setHelp('Example: &(objectClass=inetOrgPerson)(mail=*@example.com)');
|
595
|
|
596
|
$section->add($group);
|
597
|
|
598
|
$section->addInput(new Form_Checkbox(
|
599
|
'ldap_anon',
|
600
|
'Bind anonymous',
|
601
|
'Use anonymous binds to resolve distinguished names',
|
602
|
$pconfig['ldap_anon']
|
603
|
));
|
604
|
|
605
|
$group = new Form_Group('Bind credentials');
|
606
|
$group->addClass('ldapanon');
|
607
|
|
608
|
$group->add(new Form_Input(
|
609
|
'ldap_binddn',
|
610
|
'User DN:',
|
611
|
'text',
|
612
|
$pconfig['ldap_binddn']
|
613
|
));
|
614
|
|
615
|
$group->add(new Form_Input(
|
616
|
'ldap_bindpw',
|
617
|
'Password',
|
618
|
'text',
|
619
|
$pconfig['ldap_bindpw']
|
620
|
));
|
621
|
$section->add($group);
|
622
|
|
623
|
if (!isset($id)) {
|
624
|
$template_list = array();
|
625
|
|
626
|
foreach($ldap_templates as $option => $template) {
|
627
|
$template_list[$option] = $template['desc'];
|
628
|
}
|
629
|
|
630
|
$section->addInput(new Form_Select(
|
631
|
'ldap_tmpltype',
|
632
|
'Initial Template',
|
633
|
$pconfig['ldap_template'],
|
634
|
$template_list
|
635
|
));
|
636
|
}
|
637
|
|
638
|
$section->addInput(new Form_Input(
|
639
|
'ldap_attr_user',
|
640
|
'User naming attribute',
|
641
|
'text',
|
642
|
$pconfig['ldap_attr_user']
|
643
|
));
|
644
|
|
645
|
$section->addInput(new Form_Input(
|
646
|
'ldap_attr_group',
|
647
|
'Group naming attribute',
|
648
|
'text',
|
649
|
$pconfig['ldap_attr_group']
|
650
|
));
|
651
|
|
652
|
$section->addInput(new Form_Input(
|
653
|
'ldap_attr_member',
|
654
|
'Group member attribute',
|
655
|
'text',
|
656
|
$pconfig['ldap_attr_member']
|
657
|
));
|
658
|
|
659
|
$section->addInput(new Form_Checkbox(
|
660
|
'ldap_rfc2307',
|
661
|
'RFC 2307 Groups',
|
662
|
'LDAP Server uses RFC 2307 style group membership',
|
663
|
$pconfig['ldap_rfc2307']
|
664
|
))->setHelp('RFC 2307 style group membership has members listed on the group '.
|
665
|
'object rather than using groups listed on user object. Leave unchecked '.
|
666
|
'for Active Directory style group membership (RFC 2307bis).');
|
667
|
|
668
|
$section->addInput(new Form_Input(
|
669
|
'ldap_attr_groupobj',
|
670
|
'Group Object Class',
|
671
|
'text',
|
672
|
$pconfig['ldap_attr_groupobj'],
|
673
|
['placeholder' => 'posixGroup']
|
674
|
))->setHelp('Object class used for groups in RFC2307 mode. '.
|
675
|
'Typically "posixGroup" or "group".');
|
676
|
|
677
|
$section->addInput(new Form_Checkbox(
|
678
|
'ldap_utf8',
|
679
|
'UTF8 Encode',
|
680
|
'UTF8 encode LDAP parameters before sending them to the server.',
|
681
|
$pconfig['ldap_utf8']
|
682
|
))->setHelp('Required to support international characters, but may not be '.
|
683
|
'supported by every LDAP server.');
|
684
|
|
685
|
$section->addInput(new Form_Checkbox(
|
686
|
'ldap_nostrip_at',
|
687
|
'Username Alterations',
|
688
|
'Do not strip away parts of the username after the @ symbol',
|
689
|
$pconfig['ldap_nostrip_at']
|
690
|
))->setHelp('e.g. user@host becomes user when unchecked.');
|
691
|
|
692
|
$form->add($section);
|
693
|
|
694
|
// ==== RADIUS section ========================================================
|
695
|
$section = new Form_Section('RADIUS Server Settings');
|
696
|
$section->addClass('toggle-radius collapse');
|
697
|
|
698
|
$section->addInput(new Form_Input(
|
699
|
'radius_host',
|
700
|
'Hostname or IP address',
|
701
|
'text',
|
702
|
$pconfig['radius_host']
|
703
|
));
|
704
|
|
705
|
$section->addInput(new Form_Input(
|
706
|
'radius_secret',
|
707
|
'Shared Secret',
|
708
|
'text',
|
709
|
$pconfig['radius_secret']
|
710
|
));
|
711
|
|
712
|
$section->addInput(new Form_Select(
|
713
|
'radius_srvcs',
|
714
|
'Services offered',
|
715
|
$pconfig['radius_srvcs'],
|
716
|
$radius_srvcs
|
717
|
));
|
718
|
|
719
|
$section->addInput(new Form_Input(
|
720
|
'radius_auth_port',
|
721
|
'Authentication port',
|
722
|
'number',
|
723
|
$pconfig['radius_auth_port']
|
724
|
));
|
725
|
|
726
|
$section->addInput(new Form_Input(
|
727
|
'radius_acct_port',
|
728
|
'Accounting port',
|
729
|
'number',
|
730
|
$pconfig['radius_acct_port']
|
731
|
));
|
732
|
|
733
|
$section->addInput(new Form_Input(
|
734
|
'radius_timeout',
|
735
|
'Authentication Timeout',
|
736
|
'number',
|
737
|
$pconfig['radius_timeout']
|
738
|
))->setHelp('This value controls how long, in seconds, that the RADIUS '.
|
739
|
'server may take to respond to an authentication request. If left blank, the '.
|
740
|
'default value is 5 seconds. NOTE: If you are using an interactive two-factor '.
|
741
|
'authentication system, increase this timeout to account for how long it will '.
|
742
|
'take the user to receive and enter a token.');
|
743
|
|
744
|
if (isset($id) && $a_server[$id])
|
745
|
{
|
746
|
$section->addInput(new Form_Input(
|
747
|
'id',
|
748
|
null,
|
749
|
'hidden',
|
750
|
$id
|
751
|
));
|
752
|
}
|
753
|
|
754
|
$form->add($section);
|
755
|
print $form;
|
756
|
?>
|
757
|
<script type="text/javascript">
|
758
|
//<![CDATA[
|
759
|
events.push(function(){
|
760
|
function select_clicked() {
|
761
|
if (document.getElementById("ldap_port").value == '' ||
|
762
|
document.getElementById("ldap_host").value == '' ||
|
763
|
document.getElementById("ldap_scope").value == '' ||
|
764
|
document.getElementById("ldap_basedn").value == '' ||
|
765
|
document.getElementById("ldapauthcontainers").value == '') {
|
766
|
alert("<?=gettext("Please fill the required values.");?>");
|
767
|
return;
|
768
|
}
|
769
|
|
770
|
if (!document.getElementById("ldap_anon").checked) {
|
771
|
if (document.getElementById("ldap_binddn").value == '' ||
|
772
|
document.getElementById("ldap_bindpw").value == '') {
|
773
|
alert("<?=gettext("Please fill the bind username/password.");?>");
|
774
|
return;
|
775
|
}
|
776
|
}
|
777
|
var url = 'system_usermanager_settings_ldapacpicker.php?';
|
778
|
url += 'port=' + document.getElementById("ldap_port").value;
|
779
|
url += '&host=' + document.getElementById("ldap_host").value;
|
780
|
url += '&scope=' + document.getElementById("ldap_scope").value;
|
781
|
url += '&basedn=' + document.getElementById("ldap_basedn").value;
|
782
|
url += '&binddn=' + document.getElementById("ldap_binddn").value;
|
783
|
url += '&bindpw=' + document.getElementById("ldap_bindpw").value;
|
784
|
url += '&urltype=' + document.getElementById("ldap_urltype").value;
|
785
|
url += '&proto=' + document.getElementById("ldap_protver").value;
|
786
|
url += '&authcn=' + document.getElementById("ldapauthcontainers").value;
|
787
|
<?php if (count($a_ca) > 0): ?>
|
788
|
url += '&cert=' + document.getElementById("ldap_caref").value;
|
789
|
<?php else: ?>
|
790
|
url += '&cert=';
|
791
|
<?php endif; ?>
|
792
|
|
793
|
var oWin = window.open(url, "pfSensePop", "width=620,height=400,top=150,left=150");
|
794
|
if (oWin == null || typeof(oWin) == "undefined") {
|
795
|
alert("<?=gettext('Popup blocker detected. Action aborted.');?>");
|
796
|
}
|
797
|
}
|
798
|
|
799
|
function set_ldap_port() {
|
800
|
if($('#ldap_urltype').find(":selected").index() == 0)
|
801
|
$('#ldap_port').val('389');
|
802
|
else
|
803
|
$('#ldap_port').val('636');
|
804
|
}
|
805
|
|
806
|
// Hides all elements of the specified class. This will usually be a section
|
807
|
function hideClass(s_class, hide) {
|
808
|
if(hide)
|
809
|
$('.' + s_class).hide();
|
810
|
else
|
811
|
$('.' + s_class).show();
|
812
|
}
|
813
|
|
814
|
function ldap_tmplchange() {
|
815
|
switch ($('#ldap_tmpltype').find(":selected").index()) {
|
816
|
<?php
|
817
|
$index = 0;
|
818
|
foreach ($ldap_templates as $tmpldata):
|
819
|
?>
|
820
|
case <?=$index;?>:
|
821
|
$('#ldap_attr_user').val("<?=$tmpldata['attr_user'];?>");
|
822
|
$('#ldap_attr_group').val("<?=$tmpldata['attr_group'];?>");
|
823
|
$('#ldap_attr_member').val("<?=$tmpldata['attr_member'];?>");
|
824
|
break;
|
825
|
<?php
|
826
|
$index++;
|
827
|
endforeach;
|
828
|
?>
|
829
|
}
|
830
|
}
|
831
|
|
832
|
// ---------- On initial page load ------------------------------------------------------------
|
833
|
|
834
|
<?php if ($act != 'edit') : ?>
|
835
|
ldap_tmplchange();
|
836
|
<?php endif; ?>
|
837
|
|
838
|
hideClass('ldapanon', $('#ldap_anon').prop('checked'));
|
839
|
$("#Select").prop('type','button');
|
840
|
hideClass('extended', !$('#ldap_extended_enabled').prop('checked'));
|
841
|
|
842
|
if($('#ldap_port').val() == "")
|
843
|
set_ldap_port();
|
844
|
|
845
|
<?php
|
846
|
if($act == 'edit') {
|
847
|
?>
|
848
|
$('#type option:not(:selected)').each(function(){
|
849
|
$(this).attr('disabled', 'disabled');
|
850
|
});
|
851
|
|
852
|
<?php
|
853
|
if(!$input_errors) {
|
854
|
?>
|
855
|
$('#name').prop("readonly", true);
|
856
|
<?php
|
857
|
}
|
858
|
}
|
859
|
?>
|
860
|
// ---------- Click checkbox handlers ---------------------------------------------------------
|
861
|
|
862
|
$('#ldap_tmpltype').on('change', function() {
|
863
|
ldap_tmplchange();
|
864
|
});
|
865
|
|
866
|
$('#ldap_anon').click(function () {
|
867
|
hideClass('ldapanon', this.checked);
|
868
|
});
|
869
|
|
870
|
$('#ldap_urltype').on('change', function() {
|
871
|
set_ldap_port();
|
872
|
});
|
873
|
|
874
|
$('#Select').click(function () {
|
875
|
select_clicked();
|
876
|
});
|
877
|
|
878
|
$('#ldap_extended_enabled').click(function () {
|
879
|
hideClass('extended', !this.checked);
|
880
|
});
|
881
|
|
882
|
});
|
883
|
//]]>
|
884
|
</script>
|
885
|
<?php
|
886
|
include("foot.inc");
|