Project

General

Profile

Download (19.6 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
	system_authservers.php
4
*/
5
/* ====================================================================
6
 *	Copyright (c)  2004-2015  Electric Sheep Fencing, LLC. All rights reserved.
7
 *	Copyright (c)  2004, 2005 Scott Ullrich
8
 *	Copyright (c)  2008 Shrew Soft Inc.
9
 *	Copyright (c)  2010 Ermal Luçi
10
 *
11
 *	Redistribution and use in source and binary forms, with or without modification,
12
 *	are permitted provided that the following conditions are met:
13
 *
14
 *	1. Redistributions of source code must retain the above copyright notice,
15
 *		this list of conditions and the following disclaimer.
16
 *
17
 *	2. Redistributions in binary form must reproduce the above copyright
18
 *		notice, this list of conditions and the following disclaimer in
19
 *		the documentation and/or other materials provided with the
20
 *		distribution.
21
 *
22
 *	3. All advertising materials mentioning features or use of this software
23
 *		must display the following acknowledgment:
24
 *		"This product includes software developed by the pfSense Project
25
 *		 for use in the pfSense software distribution. (http://www.pfsense.org/).
26
 *
27
 *	4. The names "pfSense" and "pfSense Project" must not be used to
28
 *		 endorse or promote products derived from this software without
29
 *		 prior written permission. For written permission, please contact
30
 *		 coreteam@pfsense.org.
31
 *
32
 *	5. Products derived from this software may not be called "pfSense"
33
 *		nor may "pfSense" appear in their names without prior written
34
 *		permission of the Electric Sheep Fencing, LLC.
35
 *
36
 *	6. Redistributions of any form whatsoever must retain the following
37
 *		acknowledgment:
38
 *
39
 *	"This product includes software developed by the pfSense Project
40
 *	for use in the pfSense software distribution (http://www.pfsense.org/).
41
 *
42
 *	THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
43
 *	EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
44
 *	IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
45
 *	PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
46
 *	ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
47
 *	SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
48
 *	NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
49
 *	LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50
 *	HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
51
 *	STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
52
 *	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
53
 *	OF THE POSSIBILITY OF SUCH DAMAGE.
54
 *
55
 *	====================================================================
56
 *
57
 */
58
/*
59
	pfSense_MODULE: auth
60
*/
61

    
62
##|+PRIV
63
##|*IDENT=page-system-authservers
64
##|*NAME=System: Authentication Servers
65
##|*DESCR=Allow access to the 'System: Authentication Servers' page.
66
##|*MATCH=system_authservers.php*
67
##|-PRIV
68

    
69
require("guiconfig.inc");
70
require_once("auth.inc");
71

    
72
$pgtitle = array(gettext("System"), gettext("Authentication Servers"));
73
$shortcut_section = "authentication";
74

    
75
if (is_numericint($_GET['id'])) {
76
	$id = $_GET['id'];
77
}
78
if (isset($_POST['id']) && is_numericint($_POST['id'])) {
79
	$id = $_POST['id'];
80
}
81

    
82
if (!is_array($config['system']['authserver'])) {
83
	$config['system']['authserver'] = array();
84
}
85

    
86
$a_servers = auth_get_authserver_list();
87
foreach ($a_servers as $servers) {
88
	$a_server[] = $servers;
89
}
90

    
91
if (!is_array($config['ca'])) {
92
	$config['ca'] = array();
93
}
94
$a_ca =& $config['ca'];
95

    
96
$act = $_GET['act'];
97
if ($_POST['act']) {
98
	$act = $_POST['act'];
99
}
100

    
101
if ($act == "del") {
102

    
103
	if (!$a_server[$_GET['id']]) {
104
		pfSenseHeader("system_authservers.php");
105
		exit;
106
	}
107

    
108
	/* Remove server from main list. */
109
	$serverdeleted = $a_server[$_GET['id']]['name'];
110
	foreach ($config['system']['authserver'] as $k => $as) {
111
		if ($config['system']['authserver'][$k]['name'] == $serverdeleted) {
112
			unset($config['system']['authserver'][$k]);
113
		}
114
	}
115

    
116
	/* Remove server from temp list used later on this page. */
117
	unset($a_server[$_GET['id']]);
118

    
119
	$savemsg = gettext("Authentication Server") . " " . htmlspecialchars($serverdeleted) . " " . gettext("deleted") . "<br />";
120
	write_config($savemsg);
121
}
122

    
123
if ($act == "edit") {
124
	if (isset($id) && $a_server[$id]) {
125

    
126
		$pconfig['type'] = $a_server[$id]['type'];
127
		$pconfig['name'] = $a_server[$id]['name'];
128

    
129
		if ($pconfig['type'] == "ldap") {
130
			$pconfig['ldap_caref'] = $a_server[$id]['ldap_caref'];
131
			$pconfig['ldap_host'] = $a_server[$id]['host'];
132
			$pconfig['ldap_port'] = $a_server[$id]['ldap_port'];
133
			$pconfig['ldap_urltype'] = $a_server[$id]['ldap_urltype'];
134
			$pconfig['ldap_protver'] = $a_server[$id]['ldap_protver'];
135
			$pconfig['ldap_scope'] = $a_server[$id]['ldap_scope'];
136
			$pconfig['ldap_basedn'] = $a_server[$id]['ldap_basedn'];
137
			$pconfig['ldap_authcn'] = $a_server[$id]['ldap_authcn'];
138
			$pconfig['ldap_extended_enabled'] = $a_server[$id]['ldap_extended_enabled'];
139
			$pconfig['ldap_extended_query'] = $a_server[$id]['ldap_extended_query'];
140
			$pconfig['ldap_binddn'] = $a_server[$id]['ldap_binddn'];
141
			$pconfig['ldap_bindpw'] = $a_server[$id]['ldap_bindpw'];
142
			$pconfig['ldap_attr_user'] = $a_server[$id]['ldap_attr_user'];
143
			$pconfig['ldap_attr_group'] = $a_server[$id]['ldap_attr_group'];
144
			$pconfig['ldap_attr_member'] = $a_server[$id]['ldap_attr_member'];
145
			$pconfig['ldap_utf8'] = isset($a_server[$id]['ldap_utf8']);
146
			$pconfig['ldap_nostrip_at'] = isset($a_server[$id]['ldap_nostrip_at']);
147

    
148
			if (!$pconfig['ldap_binddn'] || !$pconfig['ldap_bindpw']) {
149
				$pconfig['ldap_anon'] = true;
150
			}
151
		}
152

    
153
		if ($pconfig['type'] == "radius") {
154
			$pconfig['radius_host'] = $a_server[$id]['host'];
155
			$pconfig['radius_auth_port'] = $a_server[$id]['radius_auth_port'];
156
			$pconfig['radius_acct_port'] = $a_server[$id]['radius_acct_port'];
157
			$pconfig['radius_secret'] = $a_server[$id]['radius_secret'];
158
			$pconfig['radius_timeout'] = $a_server[$id]['radius_timeout'];
159

    
160
			if ($pconfig['radius_auth_port'] &&
161
				$pconfig['radius_acct_port']) {
162
				$pconfig['radius_srvcs'] = "both";
163
			}
164

    
165
			if ($pconfig['radius_auth_port'] &&
166
				!$pconfig['radius_acct_port']) {
167
				$pconfig['radius_srvcs'] = "auth";
168
				$pconfig['radius_acct_port'] = 1813;
169
			}
170

    
171
			if (!$pconfig['radius_auth_port'] &&
172
				$pconfig['radius_acct_port']) {
173
				$pconfig['radius_srvcs'] = "acct";
174
				$pconfig['radius_auth_port'] = 1812;
175
			}
176

    
177
		}
178
	}
179
}
180

    
181
if ($act == "new") {
182
	$pconfig['ldap_protver'] = 3;
183
	$pconfig['ldap_anon'] = true;
184
	$pconfig['radius_srvcs'] = "both";
185
	$pconfig['radius_auth_port'] = "1812";
186
	$pconfig['radius_acct_port'] = "1813";
187
}
188

    
189
if ($_POST) {
190
	unset($input_errors);
191
	$pconfig = $_POST;
192

    
193
	/* input validation */
194

    
195
	if ($pconfig['type'] == "ldap") {
196
		$reqdfields = explode(" ",
197
			"name type ldap_host ldap_port " .
198
			"ldap_urltype ldap_protver ldap_scope " .
199
			"ldap_attr_user ldap_attr_group ldap_attr_member ldapauthcontainers");
200
		$reqdfieldsn = array(
201
			gettext("Descriptive name"),
202
			gettext("Type"),
203
			gettext("Hostname or IP"),
204
			gettext("Port value"),
205
			gettext("Transport"),
206
			gettext("Protocol version"),
207
			gettext("Search level"),
208
			gettext("User naming Attribute"),
209
			gettext("Group naming Attribute"),
210
			gettext("Group member attribute"),
211
			gettext("Authentication container"));
212

    
213
		if (!$pconfig['ldap_anon']) {
214
			$reqdfields[] = "ldap_binddn";
215
			$reqdfields[] = "ldap_bindpw";
216
			$reqdfieldsn[] = gettext("Bind user DN");
217
			$reqdfieldsn[] = gettext("Bind Password");
218
		}
219
	}
220

    
221
	if ($pconfig['type'] == "radius") {
222
		$reqdfields = explode(" ", "name type radius_host radius_srvcs");
223
		$reqdfieldsn = array(
224
			gettext("Descriptive name"),
225
			gettext("Type"),
226
			gettext("Hostname or IP"),
227
			gettext("Services"));
228

    
229
		if ($pconfig['radisu_srvcs'] == "both" ||
230
			$pconfig['radisu_srvcs'] == "auth") {
231
			$reqdfields[] = "radius_auth_port";
232
			$reqdfieldsn[] = gettext("Authentication port");
233
		}
234

    
235
		if ($pconfig['radisu_srvcs'] == "both" ||
236
			$pconfig['radisu_srvcs'] == "acct") {
237
			$reqdfields[] = "radius_acct_port";
238
			$reqdfieldsn[] = gettext("Accounting port");
239
		}
240

    
241
		if (!isset($id)) {
242
			$reqdfields[] = "radius_secret";
243
			$reqdfieldsn[] = gettext("Shared Secret");
244
		}
245
	}
246

    
247
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
248

    
249
	if (preg_match("/[^a-zA-Z0-9\.\-_]/", $_POST['host'])) {
250
		$input_errors[] = gettext("The host name contains invalid characters.");
251
	}
252

    
253
	if (auth_get_authserver($pconfig['name']) && !isset($id)) {
254
		$input_errors[] = gettext("An authentication server with the same name already exists.");
255
	}
256

    
257
	if (($pconfig['type'] == "radius") && isset($_POST['radius_timeout']) && !empty($_POST['radius_timeout']) && (!is_numeric($_POST['radius_timeout']) || (is_numeric($_POST['radius_timeout']) && ($_POST['radius_timeout'] <= 0)))) {
258
		$input_errors[] = gettext("RADIUS Timeout value must be numeric and positive.");
259
	}
260

    
261
	/* if this is an AJAX caller then handle via JSON */
262
	if (isAjax() && is_array($input_errors)) {
263
		input_errors2Ajax($input_errors);
264
		exit;
265
	}
266

    
267
	if (!$input_errors) {
268
		$server = array();
269
		$server['refid'] = uniqid();
270
		if (isset($id) && $a_server[$id]) {
271
			$server = $a_server[$id];
272
		}
273

    
274
		$server['type'] = $pconfig['type'];
275
		$server['name'] = $pconfig['name'];
276

    
277
		if ($server['type'] == "ldap") {
278

    
279
			if (!empty($pconfig['ldap_caref'])) {
280
				$server['ldap_caref'] = $pconfig['ldap_caref'];
281
			}
282
			$server['host'] = $pconfig['ldap_host'];
283
			$server['ldap_port'] = $pconfig['ldap_port'];
284
			$server['ldap_urltype'] = $pconfig['ldap_urltype'];
285
			$server['ldap_protver'] = $pconfig['ldap_protver'];
286
			$server['ldap_scope'] = $pconfig['ldap_scope'];
287
			$server['ldap_basedn'] = $pconfig['ldap_basedn'];
288
			$server['ldap_authcn'] = $pconfig['ldapauthcontainers'];
289
			$server['ldap_extended_enabled'] = $pconfig['ldap_extended_enabled'];
290
			$server['ldap_extended_query'] = $pconfig['ldap_extended_query'];
291
			$server['ldap_attr_user'] = $pconfig['ldap_attr_user'];
292
			$server['ldap_attr_group'] = $pconfig['ldap_attr_group'];
293
			$server['ldap_attr_member'] = $pconfig['ldap_attr_member'];
294
			if ($pconfig['ldap_utf8'] == "yes") {
295
				$server['ldap_utf8'] = true;
296
			} else {
297
				unset($server['ldap_utf8']);
298
			}
299
			if ($pconfig['ldap_nostrip_at'] == "yes") {
300
				$server['ldap_nostrip_at'] = true;
301
			} else {
302
				unset($server['ldap_nostrip_at']);
303
			}
304

    
305

    
306
			if (!$pconfig['ldap_anon']) {
307
				$server['ldap_binddn'] = $pconfig['ldap_binddn'];
308
				$server['ldap_bindpw'] = $pconfig['ldap_bindpw'];
309
			} else {
310
				unset($server['ldap_binddn']);
311
				unset($server['ldap_bindpw']);
312
			}
313
		}
314

    
315
		if ($server['type'] == "radius") {
316

    
317
			$server['host'] = $pconfig['radius_host'];
318

    
319
			if ($pconfig['radius_secret']) {
320
				$server['radius_secret'] = $pconfig['radius_secret'];
321
			}
322

    
323
			if ($pconfig['radius_timeout']) {
324
				$server['radius_timeout'] = $pconfig['radius_timeout'];
325
			} else {
326
				$server['radius_timeout'] = 5;
327
			}
328

    
329
			if ($pconfig['radius_srvcs'] == "both") {
330
				$server['radius_auth_port'] = $pconfig['radius_auth_port'];
331
				$server['radius_acct_port'] = $pconfig['radius_acct_port'];
332
			}
333

    
334
			if ($pconfig['radius_srvcs'] == "auth") {
335
				$server['radius_auth_port'] = $pconfig['radius_auth_port'];
336
				unset($server['radius_acct_port']);
337
			}
338

    
339
			if ($pconfig['radius_srvcs'] == "acct") {
340
				$server['radius_acct_port'] = $pconfig['radius_acct_port'];
341
				unset($server['radius_auth_port']);
342
			}
343
		}
344

    
345
		if (isset($id) && $config['system']['authserver'][$id]) {
346
			$config['system']['authserver'][$id] = $server;
347
		} else {
348
			$config['system']['authserver'][] = $server;
349
		}
350

    
351
		write_config();
352

    
353
		pfSenseHeader("system_authservers.php");
354
	}
355
}
356

    
357
include("head.inc");
358

    
359
if ($input_errors)
360
	print_input_errors($input_errors);
361
if ($savemsg)
362
	print_info_box($savemsg);
363

    
364
$tab_array = array();
365
$tab_array[] = array(gettext("Users"), false, "system_usermanager.php");
366
$tab_array[] = array(gettext("Groups"), false, "system_groupmanager.php");
367
$tab_array[] = array(gettext("Settings"), false, "system_usermanager_settings.php");
368
$tab_array[] = array(gettext("Servers"), true, "system_authservers.php");
369
display_top_tabs($tab_array);
370

    
371
if (!($act == "new" || $act == "edit" || $input_errors))
372
{
373
	?>
374
	<div class="table-responsive">
375
		<table class="table table-striped table-hover">
376
			<thead>
377
				<tr>
378
					<th><?=gettext("Server Name")?></th>
379
					<th><?=gettext("Type")?></th>
380
					<th><?=gettext("Host Name")?></th>
381
					<th></th>
382
				</tr>
383
			</thead>
384
			<tbody>
385
		<?php foreach($a_server as $i => $server): ?>
386
				<tr>
387
					<td><?=htmlspecialchars($server['name'])?></td>
388
					<td><?=htmlspecialchars($auth_server_types[$server['type']])?></td>
389
					<td><?=htmlspecialchars($server['host'])?></td>
390
					<td>
391
					<?php if ($i < (count($a_server) - 1)): ?>
392
						<a href="system_authservers.php?act=edit&amp;id=<?=$i?>" class="btn btn-xs btn-primary">edit</a>
393
						<a href="system_authservers.php?act=del&amp;id=<?=$i?>" class="btn btn-xs btn-danger">delete</a>
394
					<?php endif?>
395
					</td>
396
				</tr>
397
		<?php endforeach; ?>
398
			</tbody>
399
		</table>
400
	</div>
401

    
402
	<nav class="action-buttons">
403
		<a href="?act=new" class="btn btn-success">add new</a>
404
	</nav>
405
<?php
406
	include("foot.inc");
407
	exit;
408
}
409

    
410
require('classes/Form.class.php');
411
$form = new Form;
412
$form->setAction('system_authservers.php?act=edit');
413
$form->addGlobal(new Form_Input(
414
	'userid',
415
	null,
416
	'hidden',
417
	$id
418
));
419

    
420
$section = new Form_Section('Server settings');
421

    
422
$section->addInput($input = new Form_Input(
423
	'name',
424
	'Descriptive name',
425
	'text',
426
	$pconfig['name']
427
));
428

    
429
if ($act == 'edit')
430
	$input->setReadonly();
431

    
432
$section->addInput($input = new Form_Select(
433
	'type',
434
	'Type',
435
	$pconfig['type'],
436
	$auth_server_types
437
))->toggles();
438

    
439
if ($act == 'edit')
440
	$input->setDisabled();
441

    
442
$form->add($section);
443
$section = new Form_Section('LDAP Server Settings');
444
$section->addClass('toggle-ldap collapse');
445

    
446
if (!isset($pconfig['type']) || $pconfig['type'] == 'ldap')
447
	$section->addClass('in');
448

    
449
$section->addInput(new Form_Input(
450
	'ldap_host',
451
	'Hostname or IP address',
452
	'text',
453
	$pconfig['ldap_host']
454
))->setHelp('NOTE: When using SSL, this hostname MUST match the Common Name '.
455
	'(CN) of the LDAP server\'s SSL Certificate.');
456

    
457
$section->addInput(new Form_Input(
458
	'ldap_port',
459
	'Port value',
460
	'number',
461
	$pconfig['ldap_port']
462
));
463

    
464
$section->addInput(new Form_Select(
465
	'ldap_urltype',
466
	'Transport',
467
	$pconfig['ldap_urltype'],
468
	array_combine(array_keys($ldap_urltypes), array_keys($ldap_urltypes))
469
));
470

    
471
if (empty($a_ca))
472
{
473
	$section->addInput(new Form_StaticText(
474
		'Peer Certificate Authority',
475
		'No Certificate Authorities defined.<br/>Create one under <a href="system_camanager.php">System &gt; Cert Manager</a>.'
476
	));
477
}
478
else
479
{
480
	$ldapCaRef = [];
481
	foreach ($a_ca as $ca)
482
		$ldapCaRef[ $ca['refid'] ] = $ca['descr'];
483

    
484
	$section->addInput(new Form_Select(
485
		'ldap_caref',
486
		'Peer Certificate Authority',
487
		$pconfig['ldap_caref'],
488
		$ldapCaRef
489
	))->setHelp('This option is used if \'SSL Encrypted\' option is choosen. '.
490
		'It must match with the CA in the AD otherwise problems will arise.');
491
}
492

    
493
$section->addInput(new Form_Select(
494
	'ldap_protver',
495
	'Protocol version',
496
	$pconfig['ldap_protver'],
497
	array_combine($ldap_protvers, $ldap_protvers)
498
));
499

    
500
$section->addInput(new Form_Select(
501
	'ldap_scope',
502
	'Search scope: Level',
503
	$pconfig['ldap_scope'],
504
	$ldap_scopes
505
));
506

    
507
$section->addInput(new Form_Input(
508
	'ldap_basedn',
509
	'Base DN',
510
	'text',
511
	$pconfig['ldap_basedn']
512
));
513

    
514
$group = new Form_Group('Authentication containers');
515
$group->add(new Form_Input(
516
	'ldapauthcontainers',
517
	'Containers',
518
	'text',
519
	$pconfig['ldap_authcn']
520
))->setHelp('Note: Semi-Colon separated. This will be prepended to the search '.
521
	'base dn above or you can specify full container path containing a dc= '.
522
	'component.<br/>Example: CN=Users;DC=example,DC=com or OU=Staff;OU=Freelancers');
523
#FIXME
524
$group->add(new Form_Button(
525
	'Select',
526
	'Select a container',
527
	'/system_usermanager_settings_ldapacpicker.php?port=389&host=192.168.1.1&scope=one&basedn=CN=pfsense&binddn=&bindpw=&urltype=TCP%20-%20Standard&proto=3&authcn=OU=Staff&cert='
528
));
529
$section->add($group);
530

    
531
$section->addInput(new Form_Checkbox(
532
	'ldap_extended_enabled',
533
	'Extended query',
534
	'Enable extended query',
535
	$pconfig['ldap_extended_enabled']
536
))->toggles('.toggle-extended');
537

    
538
$group = new Form_Group('Query');
539
$group->addClass('toggle-extended collapse');
540
$group->add(new Form_Input(
541
	'ldap_extended_query',
542
	'Query',
543
	'text',
544
	$pconfig['ldap_extended_query']
545
))->setHelp('Example: &amp;(objectClass=inetOrgPerson)(mail=*@example.com)');
546

    
547
$section->add($group);
548

    
549
$section->addInput(new Form_Checkbox(
550
	'ldap_anon',
551
	'Bind anonymous',
552
	'Use anonymous binds to resolve distinguished names',
553
	$pconfig['ldap_anon']
554
))->toggles('.toggle-anon');
555

    
556
$group = new Form_Group('Bind credentials');
557
$group->addClass('toggle-anon collapse');
558
$group->add(new Form_Input(
559
	'ldap_binddn',
560
	'User DN:',
561
	'text',
562
	$pconfig['ldap_binddn']
563
));
564
$group->add(new Form_Input(
565
	'ldap_bindpw',
566
	'Password',
567
	'text',
568
	$pconfig['ldap_bindpw']
569
));
570
$section->add($group);
571

    
572
if (!isset($id)) {
573
	$template_list = array();
574

    
575
	foreach($ldap_templates as $option => $template) {
576
		$template_list[$option] = $template['desc'];
577
	}
578

    
579
	$section->addInput(new Form_Select(
580
		'ldap_tmpltype',
581
		'Initial Template',
582
		$pconfig['ldap_template'],
583
		$template_list
584
	));
585
}
586

    
587
$section->addInput(new Form_Input(
588
	'ldap_attr_user',
589
	'User naming attribute',
590
	'text',
591
	$pconfig['ldap_attr_user']
592
));
593

    
594
$section->addInput(new Form_Input(
595
	'ldap_attr_group',
596
	'Group naming attribute',
597
	'text',
598
	$pconfig['ldap_attr_group']
599
));
600

    
601
$section->addInput(new Form_Input(
602
	'ldap_attr_member',
603
	'Group member attribute',
604
	'text',
605
	$pconfig['ldap_attr_member']
606
));
607

    
608
$section->addInput(new Form_Checkbox(
609
	'ldap_utf8',
610
	'UTF8 Encode',
611
	'UTF8 encode LDAP parameters before sending them to the server.',
612
	$pconfig['ldap_utf8']
613
))->setHelp('Required to support international characters, but may not be '.
614
	'supported by every LDAP server.');
615

    
616
$section->addInput(new Form_Checkbox(
617
	'ldap_nostrip_at',
618
	'Username Alterations',
619
	'Do not strip away parts of the username after the @ symbol',
620
	$pconfig['ldap_nostrip_at']
621
))->setHelp('e.g. user@host becomes user when unchecked.');
622

    
623
$form->add($section);
624
$section = new Form_Section('Radius Server Settings');
625
$section->addClass('toggle-radius collapse');
626

    
627
$section->addInput(new Form_Input(
628
	'radius_host',
629
	'Hostname or IP address',
630
	'text',
631
	$pconfig['radius_host']
632
));
633

    
634
$section->addInput(new Form_Input(
635
	'radius_secret',
636
	'Shared Secret',
637
	'text',
638
	$pconfig['radius_secret']
639
));
640

    
641
$section->addInput(new Form_Select(
642
	'radius_srvcs',
643
	'Services offered',
644
	$pconfig['radius_srvcs'],
645
	$radius_srvcs
646
));
647

    
648
$section->addInput(new Form_Input(
649
	'radius_auth_port',
650
	'Authentication port',
651
	'number',
652
	$pconfig['radius_auth_port']
653
));
654

    
655
$section->addInput(new Form_Input(
656
	'radius_acct_port',
657
	'Accounting port',
658
	'number',
659
	$pconfig['radius_acct_port']
660
));
661

    
662
$section->addInput(new Form_Input(
663
	'radius_timeout',
664
	'Authentication Timeout',
665
	'number',
666
	$pconfig['radius_timeout']
667
))->setHelp('This value controls how long, in seconds, that the RADIUS '.
668
	'server may take to respond to an authentication request. If left blank, the '.
669
	'default value is 5 seconds. NOTE: If you are using an interactive two-factor '.
670
	'authentication system, increase this timeout to account for how long it will '.
671
	'take the user to receive and enter a token.');
672

    
673
if (isset($id) && $a_server[$id])
674
{
675
	$section->addInput(new Form_Input(
676
		'id',
677
		null,
678
		'hidden',
679
		$id
680
	));
681
}
682

    
683
$form->add($section);
684
print $form;
685
?>
686
<script>
687
//<![CDATA[
688
events.push(function(){
689
	function ldap_tmplchange() {
690
		switch ($('#ldap_tmpltype').find(":selected").index()) {
691
<?php
692
		$index = 0;
693
		foreach ($ldap_templates as $tmpldata):
694
?>
695
			case <?=$index;?>:
696
				$('#ldap_attr_user').val("<?=$tmpldata['attr_user'];?>");
697
				$('#ldap_attr_group').val("<?=$tmpldata['attr_group'];?>");
698
				$('#ldap_attr_member').val("<?=$tmpldata['attr_member'];?>");
699
				break;
700
<?php
701
			$index++;
702
		endforeach;
703
?>
704
		}
705
	}
706

    
707
	// On page load . .
708
	ldap_tmplchange();
709

    
710
	// On click . .
711
	$('#ldap_tmpltype').on('change', function() {
712
		ldap_tmplchange();
713
	});
714
});
715
//]]>
716
</script>
717
<?php
718
include("foot.inc");
(193-193/237)