Commit 3d2247b4 authored by Ad Schellevis's avatar Ad Schellevis

(auth, vouchers) Vouchers, support for custom length / easier usernames and...

(auth, vouchers) Vouchers, support for custom length / easier usernames and passwords. closes https://github.com/opnsense/core/issues/886
parent ebf6cef8
...@@ -106,6 +106,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -106,6 +106,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
if (empty($pconfig['radius_auth_port'])) { if (empty($pconfig['radius_auth_port'])) {
$pconfig['radius_auth_port'] = 1812; $pconfig['radius_auth_port'] = 1812;
} }
} elseif ($pconfig['type'] == 'voucher') {
$pconfig['simplePasswords'] = $a_server[$id]['simplePasswords'];
$pconfig['usernameLength'] = $a_server[$id]['usernameLength'];
$pconfig['passwordLength'] = $a_server[$id]['passwordLength'];
} }
} }
...@@ -141,9 +145,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -141,9 +145,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$reqdfieldsn[] = gettext("Bind user DN"); $reqdfieldsn[] = gettext("Bind user DN");
$reqdfieldsn[] = gettext("Bind Password"); $reqdfieldsn[] = gettext("Bind Password");
} }
} } elseif ($pconfig['type'] == "radius") {
if ($pconfig['type'] == "radius") {
$reqdfields = explode(" ", "name type radius_host radius_srvcs"); $reqdfields = explode(" ", "name type radius_host radius_srvcs");
$reqdfieldsn = array( $reqdfieldsn = array(
gettext("Descriptive name"), gettext("Descriptive name"),
...@@ -161,6 +163,13 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -161,6 +163,13 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$reqdfields[] = "radius_secret"; $reqdfields[] = "radius_secret";
$reqdfieldsn[] = gettext("Shared Secret"); $reqdfieldsn[] = gettext("Shared Secret");
} }
} elseif ($pconfig['type'] == "voucher") {
if (!empty($pconfig['usernameLength']) && !is_numeric($pconfig['usernameLength'])) {
$input_errors[] = gettext("username length must be a number or empty for default.");
}
if (!empty($pconfig['passwordLength']) && !is_numeric($pconfig['passwordLength'])) {
$input_errors[] = gettext("password length must be a number or empty for default.");
}
} }
do_input_validation($pconfig, $reqdfields, $reqdfieldsn, $input_errors); do_input_validation($pconfig, $reqdfields, $reqdfieldsn, $input_errors);
...@@ -239,6 +248,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -239,6 +248,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$server['radius_auth_port'] = $pconfig['radius_auth_port']; $server['radius_auth_port'] = $pconfig['radius_auth_port'];
unset($server['radius_acct_port']); unset($server['radius_acct_port']);
} }
} elseif ($server['type'] == "voucher") {
$server['simplePasswords'] = !empty($pconfig['simplePasswords']);
$server['usernameLength'] = $pconfig['usernameLength'];
$server['passwordLength'] = $pconfig['passwordLength'];
} }
if (isset($id) && isset($config['system']['authserver'][$id])) { if (isset($id) && isset($config['system']['authserver'][$id])) {
...@@ -338,6 +351,8 @@ $( document ).ready(function() { ...@@ -338,6 +351,8 @@ $( document ).ready(function() {
$(".auth_ldap").removeClass('hidden'); $(".auth_ldap").removeClass('hidden');
} else if ($("#type").val() == 'radius') { } else if ($("#type").val() == 'radius') {
$(".auth_radius").removeClass('hidden'); $(".auth_radius").removeClass('hidden');
} else if ($("#type").val() == 'voucher') {
$(".auth_voucher").removeClass('hidden');
} }
}); });
...@@ -652,6 +667,34 @@ endif; ?> ...@@ -652,6 +667,34 @@ endif; ?>
</div> </div>
</td> </td>
</tr> </tr>
<!-- Vouchers -->
<tr class="auth_voucher hidden">
<td><a id="help_for_voucher_simplepasswd" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Use simple passwords (less secure)");?></td>
<td>
<input name="simplePasswords" type="checkbox" value="yes" <?=!empty($pconfig['simplePasswords']) ? "checked=\"checked\"" : ""; ?>/>
<div class="hidden" for="help_for_voucher_simplepasswd">
<br /><?= gettext("Use simple (less secure) passwords, which are easier to read") ?>
</div>
</td>
</tr>
<tr class="auth_voucher hidden">
<td><a id="help_for_voucher_usernameLength" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Username length");?></td>
<td>
<input name="usernameLength" type="text" value="<?=$pconfig['usernameLength'];?>"/>
<div class="hidden" for="help_for_voucher_usernameLength">
<?= gettext("Specify alternative username length for generating vouchers") ?>
</div>
</td>
</tr>
<tr class="auth_voucher hidden">
<td><a id="help_for_voucher_passwordLength" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Password length");?></td>
<td>
<input name="passwordLength" type="text" value="<?=$pconfig['passwordLength'];?>"/>
<div class="hidden" for="help_for_voucher_passwordLength">
<?= gettext("Specify alternative password length for generating vouchers") ?>
</div>
</td>
</tr>
<tr> <tr>
<td>&nbsp;</td> <td>&nbsp;</td>
<td> <td>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment