Commit 59f43c12 authored by Ad Schellevis's avatar Ad Schellevis

(auth) move voucher to hotplug

parent 3ff2a47a
......@@ -389,4 +389,46 @@ class Voucher implements IAuthConnector
}
return false;
}
/**
* retrieve configuration options
* @return array
*/
public function getConfigurationOptions()
{
$fields = array();
$fields["simplePasswords"] = array();
$fields["simplePasswords"]["name"] = gettext("Use simple passwords (less secure)");
$fields["simplePasswords"]["type"] = "checkbox";
$fields["simplePasswords"]["help"] = gettext("Use simple (less secure) passwords, which are easier to read") ;
$fields["simplePasswords"]["validate"] = function($value) {
return array();
};
$fields["usernameLength"] = array();
$fields["usernameLength"]["name"] = gettext("Username length");
$fields["usernameLength"]["type"] = "text";
$fields["usernameLength"]["default"] = null;
$fields["usernameLength"]["help"] = gettext("Specify alternative username length for generating vouchers");
$fields["usernameLength"]["validate"] = function($value) {
if (!empty($value) && filter_var($value, FILTER_SANITIZE_NUMBER_INT) != $value) {
return array(gettext("username length must be a number or empty for default."));
} else {
return array();
}
};
$fields["passwordLength"] = array();
$fields["passwordLength"]["name"] = gettext("Password length");
$fields["passwordLength"]["type"] = "text";
$fields["passwordLength"]["default"] = null;
$fields["passwordLength"]["help"] = gettext("Specify alternative password length for generating vouchers");
$fields["passwordLength"]["validate"] = function($value) {
if (!empty($value) && filter_var($value, FILTER_SANITIZE_NUMBER_INT) != $value) {
return array(gettext("password length must be a number or empty for default."));
} else {
return array();
}
};
return $fields;
}
}
......@@ -110,10 +110,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
if (empty($pconfig['radius_auth_port'])) {
$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'];
} elseif (!empty($authCNFOptions[$pconfig['type']])) {
foreach ($authCNFOptions[$pconfig['type']]['additionalFields'] as $fieldname => $field) {
$pconfig[$fieldname] = $a_server[$id][$fieldname];
......@@ -170,13 +166,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$reqdfields[] = "radius_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.");
}
} elseif (!empty($authCNFOptions[$pconfig['type']])) {
foreach ($authCNFOptions[$pconfig['type']]['additionalFields'] as $fieldname => $field) {
if (!empty($field['validate'])) {
......@@ -263,10 +252,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$server['radius_auth_port'] = $pconfig['radius_auth_port'];
unset($server['radius_acct_port']);
}
} elseif ($server['type'] == "voucher") {
$server['simplePasswords'] = !empty($pconfig['simplePasswords']);
$server['usernameLength'] = $pconfig['usernameLength'];
$server['passwordLength'] = $pconfig['passwordLength'];
} elseif (!empty($authCNFOptions[$server['type']])) {
foreach ($authCNFOptions[$server['type']]['additionalFields'] as $fieldname => $field) {
$server[$fieldname] = $pconfig[$fieldname];
......@@ -674,34 +659,6 @@ endif; ?>
</div>
</td>
</tr>
<!-- Vouchers -->
<tr class="auth_voucher auth_options 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 auth_options 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 auth_options 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>
<!-- pluggable options -->
<?php
foreach ($authCNFOptions as $typename => $authtype):
......@@ -737,7 +694,7 @@ endif; ?>
</select>
<?php
elseif ($field['type'] == 'checkbox'):?>
<input name="<?=$fieldname;?>" type="checkbox" value="yes" <?=!empty($pconfig[$fieldname]) ? "checked=\"checked\"" : ""; ?>/>
<input name="<?=$fieldname;?>" type="checkbox" value="1" <?=!empty($pconfig[$fieldname]) ? "checked=\"checked\"" : ""; ?>/>
<?php
endif;?>
<div class="hidden" for="help_for_field_<?=$typename;?>_<?=$fieldname;?>">
......
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