Project

General

Profile

Download (5.09 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
	vpn_ipsec_keys.php
4
	part of m0n0wall (http://m0n0.ch/wall)
5
	part of pfSense
6

    
7
	Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>.
8
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
9
	All rights reserved.
10

    
11
	Redistribution and use in source and binary forms, with or without
12
	modification, are permitted provided that the following conditions are met:
13

    
14
	1. Redistributions of source code must retain the above copyright notice,
15
	   this list of conditions and the following disclaimer.
16

    
17
	2. Redistributions in binary form must reproduce the above copyright
18
	   notice, this list of conditions and the following disclaimer in the
19
	   documentation and/or other materials provided with the distribution.
20

    
21
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
22
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
23
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
25
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
	POSSIBILITY OF SUCH DAMAGE.
31
*/
32

    
33
##|+PRIV
34
##|*IDENT=page-vpn-ipsec-listkeys
35
##|*NAME=VPN: IPsec: Pre-Shared Keys List
36
##|*DESCR=Allow access to the 'VPN: IPsec: Pre-Shared Keys List' page.
37
##|*MATCH=vpn_ipsec_keys.php*
38
##|-PRIV
39

    
40
require("functions.inc");
41
require("guiconfig.inc");
42
require_once("ipsec.inc");
43
require_once("vpn.inc");
44
require_once("filter.inc");
45

    
46
if (!is_array($config['ipsec']['mobilekey'])) {
47
	$config['ipsec']['mobilekey'] = array();
48
}
49
ipsec_mobilekey_sort();
50
$a_secret = &$config['ipsec']['mobilekey'];
51

    
52
$userkeys = array();
53
foreach ($config['system']['user'] as $id => $user) {
54
	if (!empty($user['ipsecpsk'])) {
55
		$userkeys[] = array('ident' => $user['name'], 'type' => 'PSK', 'pre-shared-key' => $user['ipsecpsk'], 'id' => $id);;
56
	}
57
}
58

    
59
if (isset($_POST['apply'])) {
60
	$retval = vpn_ipsec_configure();
61
	/* reload the filter in the background */
62
	filter_configure();
63
	$savemsg = get_std_save_message($retval);
64
	if (is_subsystem_dirty('ipsec'))
65
		clear_subsystem_dirty('ipsec');
66
}
67

    
68
if ($_GET['act'] == "del") {
69
	if ($a_secret[$_GET['id']]) {
70
		unset($a_secret[$_GET['id']]);
71
		write_config(gettext("Deleted IPsec Pre-Shared Key"));
72
		mark_subsystem_dirty('ipsec');
73
		header("Location: vpn_ipsec_keys.php");
74
		exit;
75
	}
76
}
77

    
78
$pgtitle = gettext("VPN: IPsec: Keys");
79
$shortcut_section = "ipsec";
80

    
81
include("head.inc");
82

    
83
?>
84

    
85
<?php
86
if ($savemsg)
87
	print_info_box($savemsg);
88
if (is_subsystem_dirty('ipsec'))
89
	print_info_box_np(gettext("The IPsec tunnel configuration has been changed") . ".<br />" . gettext("You must apply the changes in order for them to take effect."));
90

    
91
?>
92

    
93
<?php
94
	$tab_array = array();
95
	$tab_array[0] = array(gettext("Tunnels"), false, "vpn_ipsec.php");
96
	$tab_array[1] = array(gettext("Mobile clients"), false, "vpn_ipsec_mobile.php");
97
	$tab_array[2] = array(gettext("Pre-Shared Keys"), true, "vpn_ipsec_keys.php");
98
	$tab_array[3] = array(gettext("Advanced Settings"), false, "vpn_ipsec_settings.php");
99
	display_top_tabs($tab_array);
100
?>
101

    
102
<div class="table-responsive">
103
	<table class="table table-striped table-hover">
104
		<thead>
105
			<tr>
106
				<th><?=gettext("Identifier"); ?></th>
107
				<th><?=gettext("Type"); ?></th>
108
				<th><?=gettext("Pre-Shared Key"); ?></th>
109
				<th></th>
110
			</tr>
111
		</thead>
112

    
113
		<tbody>
114
<?php $i = 0; foreach ($userkeys as $secretent): ?>
115
			<tr>
116
				<td>
117
					<?php
118
					if ($secretent['ident'] == 'allusers')
119
						echo gettext("ANY USER");
120
					else
121
						echo htmlspecialchars($secretent['ident']);
122
					?>
123
				</td>
124
				<td>
125
					<?php
126
					if (empty($secretent['type']))
127
						echo 'PSK';
128
					else
129
						echo htmlspecialchars($secretent['type']);
130
					?>
131
				</td>
132
				<td>
133
					<?=htmlspecialchars($secretent['pre-shared-key'])?>
134
				</td>
135
				<td>
136
					<a class="btn btn-primary btn-xs" href="system_usermanager.php?act=edit&amp;userid=<?=$secretent['id']?>">edit user</a>
137
				</td>
138
			</tr>
139
<?php $i++; endforeach; ?>
140

    
141
<?php $i = 0; foreach ($a_secret as $secretent): ?>
142
			<tr>
143
				<td>
144
					<?=htmlspecialchars($secretent['ident'])?>
145
				</td>
146
				<td>
147
					<?php
148
					if (empty($secretent['type']))
149
						echo 'PSK';
150
					else
151
						echo htmlspecialchars($secretent['type']);
152
					?>
153
				</td>
154
				<td>
155
					<?=htmlspecialchars($secretent['pre-shared-key'])?>
156
				</td>
157
				<td>
158
					<a class="btn btn-primary btn-xs" href="vpn_ipsec_keys_edit.php?id=<?=$i?>">edit key</a>
159
					<a class="btn btn-danger btn-xs" href="vpn_ipsec_keys.php?act=del&amp;id=<?=$i?>">delete key</a>
160
				</td>
161
			</tr>
162
<?php $i++; endforeach; ?>
163
		</tbody>
164
	</table>
165
</div>
166

    
167
<nav class="action-buttons">
168
	<a class="btn btn-success" href="vpn_ipsec_keys_edit.php"><?=gettext("add key")?></a>
169
</nav>
170

    
171
<div class="alert alert-info">
172
	<strong><?=gettext("Note"); ?>:</strong><br />
173
	<?=gettext("PSK for any user can be set by using an identifier of any/ANY")?>
174
</div>
175

    
176
<?php include("foot.inc"); ?>
(223-223/241)