Commit 2abee4eb authored by Ad Schellevis's avatar Ad Schellevis Committed by Franco Fichtner

(ipsec shared secrets) fix spacing, add type

PR: https://github.com/opnsense/core/issues/1214

(cherry picked from commit 5dc95bac)
(cherry picked from commit 6eea44ff)
parent bbf9655a
...@@ -807,7 +807,8 @@ EOD; ...@@ -807,7 +807,8 @@ EOD;
} else { } else {
$ident = $key['ident']; $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); unset($key);
} }
......
...@@ -60,8 +60,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { ...@@ -60,8 +60,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$savemsg = get_std_save_message(); $savemsg = get_std_save_message();
clear_subsystem_dirty('ipsec'); clear_subsystem_dirty('ipsec');
} else { } else {
// nothing to post, redirect // nothing to post, redirect
header("Location: vpn_ipsec_keys.php"); header(url_safe('Location: /vpn_ipsec_keys.php'));
exit; exit;
} }
} }
...@@ -122,55 +122,45 @@ if (is_subsystem_dirty('ipsec')) { ...@@ -122,55 +122,45 @@ if (is_subsystem_dirty('ipsec')) {
<tr> <tr>
<td><?=gettext("Identifier"); ?></td> <td><?=gettext("Identifier"); ?></td>
<td><?=gettext("Pre-Shared Key"); ?></td> <td><?=gettext("Pre-Shared Key"); ?></td>
<td><?=gettext("Type"); ?></td>
<td> <td>
<a href="vpn_ipsec_keys_edit.php" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-plus"></span></a> <a href="vpn_ipsec_keys_edit.php" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-plus"></span></a>
</td> </td>
</tr> </tr>
<?php $i = 0; <?php $i = 0;
$userkeys = array(); $userkeys = array();
foreach ($config['system']['user'] as $id => $user) { foreach ($config['system']['user'] as $id => $user) {
if (!empty($user['ipsecpsk'])) { if (!empty($user['ipsecpsk'])) {
$userkeys[] = array('ident' => $user['name'], 'pre-shared-key' => $user['ipsecpsk'], 'id' => $id); $userkeys[] = array('ident' => $user['name'], 'pre-shared-key' => $user['ipsecpsk'], 'id' => $id);
} }
} }
foreach ($userkeys as $secretent) : foreach ($userkeys as $secretent):?>
?> <tr>
<tr> <td><?=htmlspecialchars($secretent['ident']) ;?></td>
<td> <td><?=htmlspecialchars($secretent['pre-shared-key']);?></td>
<?=htmlspecialchars($secretent['ident']) ;?> <td>PSK</td>
</td> <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>
<?=htmlspecialchars($secretent['pre-shared-key']);?> </td>
</td> </tr>
<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; ?>
<?php <?php
$i++;
endforeach;
$i = 0; $i = 0;
foreach ($config['ipsec']['mobilekey'] as $secretent) : foreach ($config['ipsec']['mobilekey'] as $secretent) :?>
?> <tr>
<tr> <td><?=htmlspecialchars($secretent['ident']);?></td>
<td> <td><?=htmlspecialchars($secretent['pre-shared-key']);?></td>
<?=htmlspecialchars($secretent['ident']);?> <td><?=!empty($secretent['type']) ? htmlspecialchars($secretent['type']) : "PSK"?> </td>
</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>
<td> <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>
<?=htmlspecialchars($secretent['pre-shared-key']);?> </td>
</td> </tr>
<td> <?php
<a href="vpn_ipsec_keys_edit.php?id=<?=$i; $i++;
?>" title="<?=gettext("edit key"); ?>" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-pencil"></span></a> endforeach; ?>
<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> <tr>
<td colspan="2"> <td colspan="3">
<?=gettext("PSK for any user can be set by using an identifier of any/ANY") ?> <?=gettext("PSK for any user can be set by using an identifier of any/ANY") ?>
</td> </td>
<td> <td>
......
...@@ -49,10 +49,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -49,10 +49,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$id = $_GET['id']; $id = $_GET['id'];
$pconfig['ident'] = $config['ipsec']['mobilekey'][$id]['ident']; $pconfig['ident'] = $config['ipsec']['mobilekey'][$id]['ident'];
$pconfig['psk'] = $config['ipsec']['mobilekey'][$id]['pre-shared-key']; $pconfig['psk'] = $config['ipsec']['mobilekey'][$id]['pre-shared-key'];
$pconfig['type'] = $config['ipsec']['mobilekey'][$id]['type'];
} else { } else {
// init new // init new
$pconfig['ident'] = ''; $pconfig['ident'] = '';
$pconfig['psk'] = ''; $pconfig['psk'] = '';
$pconfig['type'] = 'PSK';
} }
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') { } elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
$input_errors = array(); $input_errors = array();
...@@ -97,6 +99,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -97,6 +99,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$secretent = array(); $secretent = array();
$secretent['ident'] = $pconfig['ident']; $secretent['ident'] = $pconfig['ident'];
$secretent['pre-shared-key'] = $pconfig['psk']; $secretent['pre-shared-key'] = $pconfig['psk'];
$secretent['type'] = $pconfig['type'];
if ($id !== null) { if ($id !== null) {
// edit existing key // edit existing key
...@@ -153,6 +156,15 @@ include("head.inc"); ...@@ -153,6 +156,15 @@ include("head.inc");
<input name="psk" type="text" class="formfld unknown" id="psk" size="40" value="<?=$pconfig['psk'];?>" /> <input name="psk" type="text" class="formfld unknown" id="psk" size="40" value="<?=$pconfig['psk'];?>" />
</td> </td>
</tr> </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> <tr>
<td>&nbsp;</td> <td>&nbsp;</td>
<td> <td>
...@@ -164,15 +176,6 @@ include("head.inc"); ...@@ -164,15 +176,6 @@ include("head.inc");
endif; ?> endif; ?>
</td> </td>
</tr> </tr>
<tr>
<td>&nbsp;</td>
<td>
<span class="text-danger">
<strong><?=gettext("Note"); ?>:<br /></strong>
</span>
<?=gettext("PSK for any user can be set by using an identifier of any/ANY");?>
</td>
</tr>
</table> </table>
</div> </div>
</form> </form>
......
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