Projet

Général

Profil

0002-interface-add-a-page-to-configure-blacklists.patch

Jérôme Schneider, 22 octobre 2014 16:24

Télécharger (6,78 ko)

Voir les différences:

Subject: [PATCH 2/3] interface: add a page to configure blacklists

 .../www/services_captiveportal_saml_blacklist.php  | 162 +++++++++++++++++++++
 usr/local/www/services_captiveportal_zones.php     |   3 +-
 2 files changed, 164 insertions(+), 1 deletion(-)
 create mode 100755 usr/local/www/services_captiveportal_saml_blacklist.php
usr/local/www/services_captiveportal_saml_blacklist.php
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
require_once("captiveportal_saml.inc");
48

  
49
if (!is_array($config['captiveportal']))
50
	$config['captiveportal'] = array();
51
$a_cp =& $config['captiveportal'];
52

  
53
if (!is_array($config['univnautes']))
54
	$config['univnautes'] = array();
55
$a_un =& $config['univnautes'];
56

  
57
if (!is_array($a_un['blacklists']))
58
    $a_un['blacklists'] = array(
59
        'macaddresses' => array(),
60
        'nameid' => array()
61
    );
62

  
63
$a_blacklist =& $a_un['blacklists'];
64

  
65
$pconfig['macaddresses'] = base64_decode($a_blacklist['macaddresses']);
66
$pconfig['nameid'] = base64_decode($a_blacklist['nameid']);
67

  
68
$pgtitle = array(gettext("Services"),gettext("Captive portal"), "SAML 2.0 Blacklists");
69
$shortcut_section = "captiveportal";
70

  
71
if ($_POST) {
72

  
73
	unset($input_errors);
74
	$pconfig = $_POST;
75

  
76
	/* input validation */
77
    $reqdfields = array();
78
	$reqdfieldsn = array();
79

  
80
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
81

  
82
    /* if this is an AJAX caller then handle via JSON */
83
    if (isAjax() && is_array($input_errors)) {
84
        input_errors2Ajax($input_errors);
85
        exit;
86
    }
87

  
88
	if (!$input_errors) {
89
		$a_blacklist['macaddresses'] = base64_encode($pconfig['macaddresses']);
90
		$a_blacklist['nameid'] = base64_encode($pconfig['nameid']);
91
		/* write config.xml */
92
		write_config();
93

  
94
		/* reload whitelists */
95
		mwexec_bg("/usr/local/univnautes/sp/rc.sh syncbl");
96

  
97
		/* back to the page */
98
		pfSenseHeader("services_captiveportal_saml_blacklist.php");
99
	}
100
}
101
include("head.inc");
102
?>
103
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
104
<?php include("fbegin.inc"); ?>
105
<?php if ($input_errors) print_input_errors($input_errors); ?>
106
<?php if ($savemsg) print_info_box($savemsg); ?>
107

  
108
<form action="services_captiveportal_saml_blacklist.php" method="post" enctype="multipart/form-data" name="iform" id="iform">
109

  
110
<table width="100%" border="0" cellpadding="0" cellspacing="0">
111
  <tr><td class="tabnavtbl"><?php display_saml_tabs(basename(__FILE__)); ?></td></tr>
112
  <tr>
113
  <td class="tabcont">
114
  <table width="100%" border="0" cellpadding="6" cellspacing="0">
115

  
116
	<tr>
117
		<td colspan="2" class="list" height="12"></td>
118
	</tr>
119

  
120

  
121
	<tr>
122
		<td valign="top" class="vncellreq"><?=gettext("Mac addresses"); ?></td>
123
		<td class="vtable">
124
        <textarea name="macaddresses" cols="65" rows="4" id="macaddresses" class="formpre"><?=htmlspecialchars($pconfig['macaddresses']);?></textarea>
125
			<br>
126
			<?=gettext("List of mac address to ban, one per line."); ?>
127
		</td>
128
	</tr>
129

  
130
	<tr>
131
		<td colspan="2" class="list" height="12"></td>
132
	</tr>
133
<tr>
134
    <td valign="top" class="vncellreq"><?=gettext("SAML NameIDs"); ?></td>
135
		<td class="vtable">
136
            <textarea name="nameid" cols="65" rows="4" id="nameid" class="formpre"><?=htmlspecialchars($pconfig['nameid']);?></textarea>
137
			<br>
138
			<?=gettext("List of NameID (SAML identifier) to ban, one per line."); ?>
139
		</td>
140
	</tr>
141

  
142
	<tr>
143
	  <td width="22%" valign="top">&nbsp;</td>
144
	  <td width="78%">
145
		<?php echo "<input name='zone' id='zone' type='hidden' value='" . htmlspecialchars($cpzone) . "'/>"; ?>
146
		<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" onClick="enable_change(true)">
147
		<a href="services_captiveportal_zones.php"><input name="Cancel" type="button" class="formbtn" value="<?=gettext("Cancel"); ?>" onClick="enable_change(true)"></a>
148
	  </td>
149
	</tr>
150
  </table>
151
  </td>
152
  </tr>
153
  </table>
154
</form>
155
<script language="JavaScript">
156
<!--
157
enable_change(false);
158
//-->
159
</script>
160
<?php include("fend.inc"); ?>
161
</body>
162
</html>
usr/local/www/services_captiveportal_zones.php
115 115
<p>
116 116
<a href="services_captiveportal_saml_sp.php">Service provider</a> |
117 117
<a href="services_captiveportal_saml_federation.php">Federations</a> |
118
<a href="services_captiveportal_saml_whitelist.php">Whitelist</a>
118
<a href="services_captiveportal_saml_whitelist.php">Whitelist</a> |
119
<a href="services_captiveportal_saml_blacklist.php">Blacklist</a>
119 120
</p>
120 121
</div>
121 122

  
122
-