1
|
<?php
|
2
|
/*
|
3
|
services_captiveportal_saml_sp.php
|
4
|
part of m0n0wall (http://m0n0.ch/wall)
|
5
|
|
6
|
Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
|
7
|
Copyright (C) 2014 Entr'ouvert <info@entrouvert.com>.
|
8
|
All rights reserved.
|
9
|
|
10
|
Redistribution and use in source and binary forms, with or without
|
11
|
modification, are permitted provided that the following conditions are met:
|
12
|
|
13
|
1. Redistributions of source code must retain the above copyright notice,
|
14
|
this list of conditions and the following disclaimer.
|
15
|
|
16
|
2. Redistributions in binary form must reproduce the above copyright
|
17
|
notice, this list of conditions and the following disclaimer in the
|
18
|
documentation and/or other materials provided with the distribution.
|
19
|
|
20
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
21
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
22
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
23
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
24
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29
|
POSSIBILITY OF SUCH DAMAGE.
|
30
|
*/
|
31
|
/*
|
32
|
pfSense_MODULE: captiveportal
|
33
|
*/
|
34
|
|
35
|
##|+PRIV
|
36
|
##|*IDENT=page-services-captiveportal-saml-sp
|
37
|
##|*NAME=Services: Captive portal SAML SP page
|
38
|
##|*DESCR=Allow access to the 'Services: Captive portal SAML SP' page.
|
39
|
##|*MATCH=services_captiveportal_saml_sp.php*
|
40
|
##|-PRIV
|
41
|
|
42
|
require_once("guiconfig.inc");
|
43
|
require_once("functions.inc");
|
44
|
require_once("filter.inc");
|
45
|
require_once("shaper.inc");
|
46
|
require_once("captiveportal.inc");
|
47
|
|
48
|
if (!is_array($config['captiveportal']))
|
49
|
$config['captiveportal'] = array();
|
50
|
$a_cp =& $config['captiveportal'];
|
51
|
|
52
|
$a_cert =& $config['cert'];
|
53
|
|
54
|
if (!is_array($config['univnautes']))
|
55
|
$config['univnautes'] = array();
|
56
|
$a_un =& $config['univnautes'];
|
57
|
|
58
|
if (!is_array($a_un['sp']))
|
59
|
$a_un['sp'] = array();
|
60
|
$a_sp =& $a_un['sp'];
|
61
|
|
62
|
$pconfig['certref'] = $a_sp['certref'];
|
63
|
$pconfig['defaultidps'] = base64_decode($a_sp['defaultidps']);
|
64
|
$pconfig['geolocations'] = base64_decode($a_sp['geolocations']);
|
65
|
$pconfig['geoinitialbounds'] = $a_sp['geoinitialbounds'];
|
66
|
|
67
|
$pgtitle = array(gettext("Services"),gettext("Captive portal"), "SAML 2.0 Service provider");
|
68
|
$shortcut_section = "captiveportal";
|
69
|
|
70
|
if ($_POST) {
|
71
|
|
72
|
unset($input_errors);
|
73
|
$pconfig = $_POST;
|
74
|
|
75
|
/* input validation */
|
76
|
$reqdfields = array("certref");
|
77
|
$reqdfieldsn = array(gettext("SP SAML 2.0 Certificate"));
|
78
|
|
79
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
|
80
|
|
81
|
/* if this is an AJAX caller then handle via JSON */
|
82
|
if (isAjax() && is_array($input_errors)) {
|
83
|
input_errors2Ajax($input_errors);
|
84
|
exit;
|
85
|
}
|
86
|
|
87
|
if (!$input_errors) {
|
88
|
$a_sp['certref'] = $pconfig['certref'];
|
89
|
$a_sp['defaultidps'] = base64_encode($pconfig['defaultidps']);
|
90
|
$a_sp['geolocations'] = base64_encode($pconfig['geolocations']);
|
91
|
$a_sp['geoinitialbounds'] = $pconfig['geoinitialbounds'];
|
92
|
/* write config.xml */
|
93
|
write_config();
|
94
|
|
95
|
/* relaunch SP */
|
96
|
mwexec_bg("/usr/local/univnautes/sp/rc.sh restart");
|
97
|
|
98
|
/* back to the page */
|
99
|
pfSenseHeader("services_captiveportal_saml_sp.php");
|
100
|
}
|
101
|
}
|
102
|
include("head.inc");
|
103
|
?>
|
104
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
105
|
<?php include("fbegin.inc"); ?>
|
106
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
107
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
108
|
|
109
|
<form action="services_captiveportal_saml_sp.php" method="post" enctype="multipart/form-data" name="iform" id="iform">
|
110
|
|
111
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
112
|
<tr><td class="tabnavtbl">
|
113
|
<?php
|
114
|
$tab_array = array();
|
115
|
$tab_array[] = array(gettext("Service provider"), true, "services_captiveportal_saml_sp.php");
|
116
|
# $tab_array[] = array(gettext("Identity provider"), false, "services_captiveportal_saml_idp.php");
|
117
|
$tab_array[] = array(gettext("Federations"), false, "services_captiveportal_saml_federation.php");
|
118
|
$tab_array[] = array(gettext("Whitelists"), false, "services_captiveportal_saml_whitelist.php");
|
119
|
display_top_tabs($tab_array, true);
|
120
|
?> </td></tr>
|
121
|
<tr>
|
122
|
<td class="tabcont">
|
123
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
124
|
|
125
|
<tr>
|
126
|
<td colspan="2" class="list" height="12"></td>
|
127
|
</tr>
|
128
|
<tr>
|
129
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("Service Provider SAML 2.0");?></td>
|
130
|
</tr>
|
131
|
|
132
|
|
133
|
<tr>
|
134
|
<td width="22%" valign="top" class="vncell"><?=gettext("SP SAML 2.0 Certificate"); ?></td>
|
135
|
<td width="78%" class="vtable">
|
136
|
<?php if (count($a_cert)): ?>
|
137
|
<select name="certref" id="certref" class="formselect">
|
138
|
<option value="__none__">None</option>
|
139
|
<?php
|
140
|
foreach($a_cert as $cert):
|
141
|
$selected = "";
|
142
|
if ($pconfig['certref'] == $cert['refid'])
|
143
|
$selected = "selected";
|
144
|
?>
|
145
|
<option value="<?=$cert['refid'];?>"<?=$selected;?>><?=$cert['descr'];?></option>
|
146
|
<?php endforeach; ?>
|
147
|
</select>
|
148
|
<?php else: ?>
|
149
|
<b><?=gettext("No Certificates defined."); ?></b> <br/>Create one under <a href="system_certmanager.php">System > Cert Manager</a>.
|
150
|
<?php endif; ?>
|
151
|
</td>
|
152
|
</tr>
|
153
|
|
154
|
<tr>
|
155
|
<td colspan="2" class="list" height="12"></td>
|
156
|
</tr>
|
157
|
<tr>
|
158
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("User interface : default Identity Providers");?></td>
|
159
|
</tr>
|
160
|
<tr>
|
161
|
<td valign="top" class="vncellreq"><?=gettext("Default IdPs"); ?></td>
|
162
|
<td class="vtable">
|
163
|
<textarea name="defaultidps" cols="65" rows="4" id="defaultidps" class="formpre"><?=htmlspecialchars($pconfig['defaultidps']);?></textarea>
|
164
|
<br>
|
165
|
<?=gettext("List of EntityIDs, one per line. These IdP will appear at the top of the list."); ?>
|
166
|
</td>
|
167
|
</tr>
|
168
|
|
169
|
<tr>
|
170
|
<td colspan="2" class="list" height="12"></td>
|
171
|
</tr>
|
172
|
<tr>
|
173
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("User interface : Map");?></td>
|
174
|
</tr>
|
175
|
|
176
|
<tr>
|
177
|
<td valign="top" class="vncellreq"><?=gettext("Geo locations"); ?></td>
|
178
|
<td class="vtable">
|
179
|
<textarea name="geolocations" cols="65" rows="4" id="geolocations" class="formpre" placeholder="https://..."><?=htmlspecialchars($pconfig['geolocations']);?></textarea>
|
180
|
<br>
|
181
|
<?=gettext("List of URLs, one per line. Example: https://static.discojuice.org/feeds/renater"); ?>
|
182
|
</td>
|
183
|
</tr>
|
184
|
<tr>
|
185
|
<td valign="top" class="vncellreq"><?=gettext("Initial bounds"); ?></td>
|
186
|
<td class="vtable">
|
187
|
<input name="geoinitialbounds" type="text" class="formfld unknown" id="geoinitialbounds" size="50" value="<?=htmlspecialchars($pconfig['geoinitialbounds']);?>" placeholder="[[left,top],[right,bottom]]" />
|
188
|
<br>
|
189
|
<?=gettext("Format : [[left,top],[right,bottom]]. Example: [[41.1,-5.53],[51.5,9.91]]"); ?>
|
190
|
</td>
|
191
|
</tr>
|
192
|
|
193
|
<tr>
|
194
|
<td width="22%" valign="top"> </td>
|
195
|
<td width="78%">
|
196
|
<?php echo "<input name='zone' id='zone' type='hidden' value='" . htmlspecialchars($cpzone) . "'/>"; ?>
|
197
|
<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" onClick="enable_change(true)">
|
198
|
<a href="services_captiveportal_zones.php"><input name="Cancel" type="button" class="formbtn" value="<?=gettext("Cancel"); ?>" onClick="enable_change(true)"></a>
|
199
|
</td>
|
200
|
</tr>
|
201
|
</table>
|
202
|
</td>
|
203
|
</tr>
|
204
|
</table>
|
205
|
</form>
|
206
|
<script language="JavaScript">
|
207
|
<!--
|
208
|
enable_change(false);
|
209
|
//-->
|
210
|
</script>
|
211
|
<?php include("fend.inc"); ?>
|
212
|
</body>
|
213
|
</html>
|