Skip to content

Commit

Permalink
(ipsec shared secrets) fix spacing, add type. closes #1214
Browse files Browse the repository at this point in the history
  • Loading branch information
AdSchellevis committed Oct 12, 2016
1 parent 029393a commit 5dc95ba
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 41 deletions.
3 changes: 2 additions & 1 deletion src/etc/inc/ipsec.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
70 changes: 30 additions & 40 deletions src/www/vpn_ipsec_keys.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
$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;
}
Expand Down Expand Up @@ -122,53 +122,43 @@
<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") ?>
Expand Down
12 changes: 12 additions & 0 deletions src/www/vpn_ipsec_keys_edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,12 @@
$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();
Expand Down Expand Up @@ -97,6 +99,7 @@
$secretent = array();
$secretent['ident'] = $pconfig['ident'];
$secretent['pre-shared-key'] = $pconfig['psk'];
$secretent['type'] = $pconfig['type'];

if ($id !== null) {
// edit existing key
Expand Down Expand Up @@ -153,6 +156,15 @@
<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>
Expand Down

0 comments on commit 5dc95ba

Please sign in to comment.