Commit 5dc95bac authored by Ad Schellevis's avatar Ad Schellevis

(ipsec shared secrets) fix spacing, add type. closes https://github.com/opnsense/core/issues/1214

parent 029393ad
......@@ -807,7 +807,8 @@ EOD;
} else {
$ident = $key['ident'];
}
$pskconf .= "{$ident} : PSK 0s".base64_encode($key['pre-shared-key'])."\n";
$identType = !empty($key['type']) ? $key['type'] : "PSK";
$pskconf .= "{$ident} : {$identType} 0s".base64_encode($key['pre-shared-key'])."\n";
}
unset($key);
}
......
......@@ -60,7 +60,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$savemsg = get_std_save_message();
clear_subsystem_dirty('ipsec');
} else {
// nothing to post, redirect
// nothing to post, redirect
header(url_safe('Location: /vpn_ipsec_keys.php'));
exit;
}
......@@ -122,53 +122,43 @@ if (is_subsystem_dirty('ipsec')) {
<tr>
<td><?=gettext("Identifier"); ?></td>
<td><?=gettext("Pre-Shared Key"); ?></td>
<td><?=gettext("Type"); ?></td>
<td>
<a href="vpn_ipsec_keys_edit.php" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-plus"></span></a>
</td>
</tr>
<?php $i = 0;
$userkeys = array();
foreach ($config['system']['user'] as $id => $user) {
if (!empty($user['ipsecpsk'])) {
$userkeys[] = array('ident' => $user['name'], 'pre-shared-key' => $user['ipsecpsk'], 'id' => $id);
}
}
foreach ($userkeys as $secretent) :
?>
<tr>
<td>
<?=htmlspecialchars($secretent['ident']) ;?>
</td>
<td>
<?=htmlspecialchars($secretent['pre-shared-key']);?>
</td>
<td>
<a href="system_usermanager.php?userid=<?=$secretent['id'];
?>&act=edit" title="<?=gettext("edit"); ?>" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-pencil"></span></a>
</td>
</tr>
<?php $i++;
endforeach; ?>
foreach ($config['system']['user'] as $id => $user) {
if (!empty($user['ipsecpsk'])) {
$userkeys[] = array('ident' => $user['name'], 'pre-shared-key' => $user['ipsecpsk'], 'id' => $id);
}
}
foreach ($userkeys as $secretent):?>
<tr>
<td><?=htmlspecialchars($secretent['ident']) ;?></td>
<td><?=htmlspecialchars($secretent['pre-shared-key']);?></td>
<td>PSK</td>
<td>
<a href="system_usermanager.php?userid=<?=$secretent['id'];?>&act=edit" title="<?=gettext("edit"); ?>" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-pencil"></span></a>
</td>
</tr>
<?php
$i++;
endforeach;
$i = 0;
foreach ($config['ipsec']['mobilekey'] as $secretent) :
?>
<tr>
<td>
<?=htmlspecialchars($secretent['ident']);?>
</td>
<td>
<?=htmlspecialchars($secretent['pre-shared-key']);?>
</td>
<td>
<a href="vpn_ipsec_keys_edit.php?id=<?=$i;
?>" title="<?=gettext("edit key"); ?>" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-pencil"></span></a>
<a id="del_<?=$i;
?>" title="<?=gettext("delete key"); ?>" class="act_delete btn btn-default btn-xs"><span class="fa fa-trash text-muted"></span></a>
</td>
</tr>
<?php $i++;
endforeach; ?>
foreach ($config['ipsec']['mobilekey'] as $secretent) :?>
<tr>
<td><?=htmlspecialchars($secretent['ident']);?></td>
<td><?=htmlspecialchars($secretent['pre-shared-key']);?></td>
<td><?=!empty($secretent['type']) ? htmlspecialchars($secretent['type']) : "PSK"?> </td>
<td><a href="vpn_ipsec_keys_edit.php?id=<?=$i;?>" title="<?=gettext("edit key"); ?>" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-pencil"></span></a>
<a id="del_<?=$i;?>" title="<?=gettext("delete key"); ?>" class="act_delete btn btn-default btn-xs"><span class="fa fa-trash text-muted"></span></a>
</td>
</tr>
<?php
$i++;
endforeach; ?>
<tr>
<td colspan="2">
<?=gettext("PSK for any user can be set by using an identifier of any/ANY") ?>
......
......@@ -49,10 +49,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$id = $_GET['id'];
$pconfig['ident'] = $config['ipsec']['mobilekey'][$id]['ident'];
$pconfig['psk'] = $config['ipsec']['mobilekey'][$id]['pre-shared-key'];
$pconfig['type'] = $config['ipsec']['mobilekey'][$id]['type'];
} else {
// init new
$pconfig['ident'] = '';
$pconfig['psk'] = '';
$pconfig['type'] = 'PSK';
}
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
$input_errors = array();
......@@ -97,6 +99,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$secretent = array();
$secretent['ident'] = $pconfig['ident'];
$secretent['pre-shared-key'] = $pconfig['psk'];
$secretent['type'] = $pconfig['type'];
if ($id !== null) {
// edit existing key
......@@ -153,6 +156,15 @@ include("head.inc");
<input name="psk" type="text" class="formfld unknown" id="psk" size="40" value="<?=$pconfig['psk'];?>" />
</td>
</tr>
<tr>
<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Type"); ?></td>
<td>
<select name="type" class="selectpicker">
<option value="PSK" <?=empty($pconfig['type']) || $pconfig['type'] == 'PSK' ? "selected=\"selected\"" : ""; ?>><?=gettext("PSK");?></option>
<option value="EAP" <?=$pconfig['type'] == "EAP" ? "selected=\"selected\"" : ""; ?>><?=gettext("EAP");?></option>
</select>
</td>
</tr>
<tr>
<td>&nbsp;</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