Merge pull request #907 from PiBa-NL/openvpn_client_usercredentials

openvpn, allow for entering client user credentials in the WebGUI
This commit is contained in:
Ermal Luçi 2014-03-19 16:50:01 +01:00
commit f3bdba41f7
2 changed files with 50 additions and 2 deletions

View File

@ -682,6 +682,14 @@ function openvpn_reconfigure($mode, $settings) {
$conf .= "ifconfig-ipv6 {$ipv6_2} {$prefix}\n";
}
if ($settings['auth_user'] && $settings['auth_pass']) {
$up_file = "{$g['varetc_path']}/openvpn/{$mode_id}.up";
$conf .= "auth-user-pass {$up_file}\n";
$userpass = "{$settings['auth_user']}\n";
$userpass .= "{$settings['auth_pass']}\n";
file_put_contents($up_file, $userpass);
}
if ($settings['proxy_addr']) {
$conf .= "http-proxy {$settings['proxy_addr']} {$settings['proxy_port']}";
if ($settings['proxy_authtype'] != "none") {

View File

@ -97,10 +97,15 @@ if($_GET['act']=="new"){
$pconfig['digest'] = "SHA1";
}
global $simplefields;
$simplefields = array('auth_user','auth_pass');
if($_GET['act']=="edit"){
if (isset($id) && $a_client[$id]) {
foreach($simplefields as $stat)
$pconfig[$stat] = $a_client[$id][$stat];
$pconfig['disable'] = isset($a_client[$id]['disable']);
$pconfig['mode'] = $a_client[$id]['mode'];
$pconfig['protocol'] = $a_client[$id]['protocol'];
@ -252,7 +257,10 @@ if ($_POST) {
if (!$input_errors) {
$client = array();
foreach($simplefields as $stat)
update_if_changed($stat, $client[$stat], $_POST[$stat]);
if ($vpnid)
$client['vpnid'] = $vpnid;
else
@ -628,6 +636,38 @@ if ($savemsg)
<tr>
<td colspan="2" class="list" height="12"></td>
</tr>
<tr>
<td colspan="2" valign="top" class="listtopic"><?=gettext("User Authentication Settings"); ?></td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell"><?=gettext("User name/pass"); ?></td>
<td width="78%" class="vtable">
<?=gettext("Leave empty when no user name and password are needed."); ?>
<br>
<table border="0" cellpadding="2" cellspacing="0">
<tr>
<td align="right" width="25%">
<span class="vexpl">
&nbsp;<?=gettext("Username"); ?> :&nbsp;
</span>
</td>
<td>
<input name="auth_user" id="auth_user" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['auth_user']);?>" />
</td>
</tr>
<tr>
<td align="right" width="25%">
<span class="vexpl">
&nbsp;<?=gettext("Password"); ?> :&nbsp;
</span>
</td>
<td>
<input name="auth_pass" id="auth_pass" type="password" class="formfld pwd" size="20" value="<?=htmlspecialchars($pconfig['auth_pass']);?>" />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2" valign="top" class="listtopic"><?=gettext("Cryptographic Settings"); ?></td>
</tr>