. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* pfSense_MODULE: captiveportal */ ##|+PRIV ##|*IDENT=page-services-captiveportal ##|*NAME=Services: Captive portal page ##|*DESCR=Allow access to the 'Services: Captive portal' page. ##|*MATCH=services_captiveportal.php* ##|-PRIV require_once("guiconfig.inc"); require_once("functions.inc"); require_once("filter.inc"); require_once("shaper.inc"); require_once("captiveportal.inc"); $cpzone = $_GET['zone']; if (isset($_POST['zone'])) $cpzone = $_POST['zone']; if (empty($cpzone) || empty($config['captiveportal'][$cpzone])) { header("Location: services_captiveportal_zones.php"); exit; } if (!is_array($config['captiveportal'])) $config['captiveportal'] = array(); $a_cp =& $config['captiveportal']; $pgtitle = array(gettext("Services"),gettext("Captive portal"), $a_cp[$cpzone]['zone']); $shortcut_section = "captiveportal"; if ($_GET['act'] == "viewhtml") { if ($a_cp[$cpzone] && $a_cp[$cpzone]['page']['htmltext']) echo base64_decode($a_cp[$cpzone]['page']['htmltext']); exit; } else if ($_GET['act'] == "viewerrhtml") { if ($a_cp[$cpzone] && $a_cp[$cpzone]['page']['errtext']) echo base64_decode($a_cp[$cpzone]['page']['errtext']); exit; } else if ($_GET['act'] == "viewlogouthtml") { if ($a_cp[$cpzone] && $a_cp[$cpzone]['page']['logouttext']) echo base64_decode($a_cp[$cpzone]['page']['logouttext']); exit; } if (!is_array($config['ca'])) $config['ca'] = array(); $a_ca =& $config['ca']; if (!is_array($config['cert'])) $config['cert'] = array(); $a_cert =& $config['cert']; if ($a_cp[$cpzone]) { $pconfig['zoneid'] = $a_cp[$cpzone]['zoneid']; $pconfig['cinterface'] = $a_cp[$cpzone]['interface']; $pconfig['maxproc'] = $a_cp[$cpzone]['maxproc']; $pconfig['maxprocperip'] = $a_cp[$cpzone]['maxprocperip']; $pconfig['timeout'] = $a_cp[$cpzone]['timeout']; $pconfig['idletimeout'] = $a_cp[$cpzone]['idletimeout']; $pconfig['freelogins_count'] = $a_cp[$cpzone]['freelogins_count']; $pconfig['freelogins_resettimeout'] = $a_cp[$cpzone]['freelogins_resettimeout']; $pconfig['freelogins_updatetimeouts'] = isset($a_cp[$cpzone]['freelogins_updatetimeouts']); $pconfig['enable'] = isset($a_cp[$cpzone]['enable']); $pconfig['pms_enabled'] = $a_cp[$cpzone]['pms_enabled']; $pconfig['auth_method'] = $a_cp[$cpzone]['auth_method']; $pconfig['radacct_enable'] = isset($a_cp[$cpzone]['radacct_enable']); $pconfig['radmac_enable'] = isset($a_cp[$cpzone]['radmac_enable']); $pconfig['radmac_secret'] = $a_cp[$cpzone]['radmac_secret']; $pconfig['reauthenticate'] = isset($a_cp[$cpzone]['reauthenticate']); $pconfig['reauthenticateacct'] = $a_cp[$cpzone]['reauthenticateacct']; $pconfig['httpslogin_enable'] = isset($a_cp[$cpzone]['httpslogin']); $pconfig['httpsname'] = $a_cp[$cpzone]['httpsname']; $pconfig['preauthurl'] = strtolower($a_cp[$cpzone]['preauthurl']); $pconfig['certref'] = $a_cp[$cpzone]['certref']; $pconfig['logoutwin_enable'] = isset($a_cp[$cpzone]['logoutwin_enable']); $pconfig['peruserbw'] = isset($a_cp[$cpzone]['peruserbw']); $pconfig['bwdefaultdn'] = $a_cp[$cpzone]['bwdefaultdn']; $pconfig['bwdefaultup'] = $a_cp[$cpzone]['bwdefaultup']; $pconfig['nomacfilter'] = isset($a_cp[$cpzone]['nomacfilter']); $pconfig['noconcurrentlogins'] = isset($a_cp[$cpzone]['noconcurrentlogins']); $pconfig['radius_protocol'] = $a_cp[$cpzone]['radius_protocol']; $pconfig['redirurl'] = $a_cp[$cpzone]['redirurl']; $pconfig['radiusip'] = $a_cp[$cpzone]['radiusip']; $pconfig['radiusip2'] = $a_cp[$cpzone]['radiusip2']; $pconfig['radiusip3'] = $a_cp[$cpzone]['radiusip3']; $pconfig['radiusip4'] = $a_cp[$cpzone]['radiusip4']; $pconfig['radiusport'] = $a_cp[$cpzone]['radiusport']; $pconfig['radiusport2'] = $a_cp[$cpzone]['radiusport2']; $pconfig['radiusport3'] = $a_cp[$cpzone]['radiusport3']; $pconfig['radiusport4'] = $a_cp[$cpzone]['radiusport4']; $pconfig['radiusacctport'] = $a_cp[$cpzone]['radiusacctport']; $pconfig['radiuskey'] = $a_cp[$cpzone]['radiuskey']; $pconfig['radiuskey2'] = $a_cp[$cpzone]['radiuskey2']; $pconfig['radiuskey3'] = $a_cp[$cpzone]['radiuskey3']; $pconfig['radiuskey4'] = $a_cp[$cpzone]['radiuskey4']; $pconfig['radiusvendor'] = $a_cp[$cpzone]['radiusvendor']; $pconfig['radiussession_timeout'] = isset($a_cp[$cpzone]['radiussession_timeout']); $pconfig['radiussrcip_attribute'] = $a_cp[$cpzone]['radiussrcip_attribute']; $pconfig['passthrumacadd'] = isset($a_cp[$cpzone]['passthrumacadd']); $pconfig['passthrumacaddusername'] = isset($a_cp[$cpzone]['passthrumacaddusername']); $pconfig['radmac_format'] = $a_cp[$cpzone]['radmac_format']; $pconfig['page'] = array(); if ($a_cp[$cpzone]['page']['htmltext']) $pconfig['page']['htmltext'] = $a_cp[$cpzone]['page']['htmltext']; if ($a_cp[$cpzone]['page']['errtext']) $pconfig['page']['errtext'] = $a_cp[$cpzone]['page']['errtext']; if ($a_cp[$cpzone]['page']['logouttext']) $pconfig['page']['logouttext'] = $a_cp[$cpzone]['page']['logouttext']; } if ($_POST) { unset($input_errors); $pconfig = $_POST; /* input validation */ if ($_POST['enable']) { $reqdfields = explode(" ", "zone cinterface"); $reqdfieldsn = array(gettext("Zone name"), gettext("Interface")); do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); /* make sure no interfaces are bridged or used on other zones */ if (is_array($_POST['cinterface'])) { foreach ($pconfig['cinterface'] as $cpbrif) { if (link_interface_to_bridge($cpbrif)) $input_errors[] = sprintf(gettext("The captive portal cannot be used on interface %s since it is part of a bridge."), $cpbrif); foreach ($a_cp as $cpkey => $cp) { if ($cpkey != $cpzone || empty($cpzone)) { if (in_array($cpbrif, explode(",", $cp['interface']))) $input_errors[] = sprintf(gettext("The captive portal cannot be used on interface %s since it is used already on %s instance."), $cpbrif, $cp['zone']); } } } } if ($_POST['httpslogin_enable']) { if (!$_POST['certref']) { $input_errors[] = gettext("Certificate must be specified for HTTPS login."); } if (!$_POST['httpsname'] || !is_domain($_POST['httpsname'])) { $input_errors[] = gettext("The HTTPS server name must be specified for HTTPS login."); } } } if ($_POST['timeout'] && (!is_numeric($_POST['timeout']) || ($_POST['timeout'] < 1))) { $input_errors[] = gettext("The timeout must be at least 1 minute."); } if ($_POST['idletimeout'] && (!is_numeric($_POST['idletimeout']) || ($_POST['idletimeout'] < 1))) { $input_errors[] = gettext("The idle timeout must be at least 1 minute."); } if ($_POST['freelogins_count'] && (!is_numeric($_POST['freelogins_count']))) { $input_errors[] = gettext("The pass-through credit count must be a number or left blank."); } else if ($_POST['freelogins_count'] && is_numeric($_POST['freelogins_count']) && ($_POST['freelogins_count'] >= 1)) { if (empty($_POST['freelogins_resettimeout']) || !is_numeric($_POST['freelogins_resettimeout']) || ($_POST['freelogins_resettimeout'] <= 0)) { $input_errors[] = gettext("The waiting period to restore pass-through credits must be above 0 hours."); } } if (($_POST['radiusip'] && !is_ipaddr($_POST['radiusip']))) { $input_errors[] = sprintf(gettext("A valid IP address must be specified. [%s]"), $_POST['radiusip']); } if (($_POST['radiusip2'] && !is_ipaddr($_POST['radiusip2']))) { $input_errors[] = sprintf(gettext("A valid IP address must be specified. [%s]"), $_POST['radiusip2']); } if (($_POST['radiusip3'] && !is_ipaddr($_POST['radiusip3']))) { $input_errors[] = sprintf(gettext("A valid IP address must be specified. [%s]"), $_POST['radiusip3']); } if (($_POST['radiusip4'] && !is_ipaddr($_POST['radiusip4']))) { $input_errors[] = sprintf(gettext("A valid IP address must be specified. [%s]"), $_POST['radiusip4']); } if (($_POST['radiusport'] && !is_port($_POST['radiusport']))) { $input_errors[] = sprintf(gettext("A valid port number must be specified. [%s]"), $_POST['radiusport']); } if (($_POST['radiusport2'] && !is_port($_POST['radiusport2']))) { $input_errors[] = sprintf(gettext("A valid port number must be specified. [%s]"), $_POST['radiusport2']); } if (($_POST['radiusport3'] && !is_port($_POST['radiusport3']))) { $input_errors[] = sprintf(gettext("A valid port number must be specified. [%s]"), $_POST['radiusport3']); } if (($_POST['radiusport4'] && !is_port($_POST['radiusport4']))) { $input_errors[] = sprintf(gettext("A valid port number must be specified. [%s]"), $_POST['radiusport4']); } if (($_POST['radiusacctport'] && !is_port($_POST['radiusacctport']))) { $input_errors[] = sprintf(gettext("A valid port number must be specified. [%s]"), $_POST['radiusacctport']); } if ($_POST['maxproc'] && (!is_numeric($_POST['maxproc']) || ($_POST['maxproc'] < 4) || ($_POST['maxproc'] > 100))) { $input_errors[] = gettext("The maximum number of concurrent connections per client IP address may not be larger than the global maximum."); } if (!$input_errors) { $newcp =& $a_cp[$cpzone]; //$newcp['zoneid'] = $a_cp[$cpzone]['zoneid']; if (empty($newcp['zoneid'])) { $newcp['zoneid'] = 8000; foreach ($a_cp as $keycpzone => $cp) if ($cp['zoneid'] == $newcp['zoneid'] && $keycpzone != $cpzone) $newcp['zoneid'] += 2; /* Resreve space for SSL config if needed */ } $oldifaces = $newcp['interface']; if (is_array($_POST['cinterface'])) $newcp['interface'] = implode(",", $_POST['cinterface']); $newcp['maxproc'] = $_POST['maxproc']; $newcp['maxprocperip'] = $_POST['maxprocperip'] ? $_POST['maxprocperip'] : false; $newcp['timeout'] = $_POST['timeout']; $newcp['idletimeout'] = $_POST['idletimeout']; $newcp['freelogins_count'] = $_POST['freelogins_count']; $newcp['freelogins_resettimeout'] = $_POST['freelogins_resettimeout']; $newcp['freelogins_updatetimeouts'] = $_POST['freelogins_updatetimeouts'] ? true : false; if ($_POST['enable']) $newcp['enable'] = true; else unset($newcp['enable']); if ($_POST['pms_enabled']) $newcp['pms_enabled'] = $_POST['pms_enabled']; else unset($newcp['pms_enabled']); $newcp['auth_method'] = $_POST['auth_method']; $newcp['radacct_enable'] = $_POST['radacct_enable'] ? true : false; $newcp['reauthenticate'] = $_POST['reauthenticate'] ? true : false; $newcp['radmac_enable'] = $_POST['radmac_enable'] ? true : false; $newcp['radmac_secret'] = $_POST['radmac_secret'] ? $_POST['radmac_secret'] : false; $newcp['reauthenticateacct'] = $_POST['reauthenticateacct']; if ($_POST['httpslogin_enable']) $newcp['httpslogin'] = true; else unset($newcp['httpslogin']); $newcp['httpsname'] = $_POST['httpsname']; $newcp['preauthurl'] = $_POST['preauthurl']; $newcp['peruserbw'] = $_POST['peruserbw'] ? true : false; $newcp['bwdefaultdn'] = $_POST['bwdefaultdn']; $newcp['bwdefaultup'] = $_POST['bwdefaultup']; $newcp['certref'] = $_POST['certref']; $newcp['logoutwin_enable'] = $_POST['logoutwin_enable'] ? true : false; $newcp['nomacfilter'] = $_POST['nomacfilter'] ? true : false; $newcp['noconcurrentlogins'] = $_POST['noconcurrentlogins'] ? true : false; $newcp['radius_protocol'] = $_POST['radius_protocol']; $newcp['redirurl'] = $_POST['redirurl']; if (isset($_POST['radiusip'])) $newcp['radiusip'] = $_POST['radiusip']; else unset($newcp['radiusip']); if (isset($_POST['radiusip2'])) $newcp['radiusip2'] = $_POST['radiusip2']; else unset($newcp['radiusip2']); if (isset($_POST['radiusip3'])) $newcp['radiusip3'] = $_POST['radiusip3']; else unset($newcp['radiusip3']); if (isset($_POST['radiusip4'])) $newcp['radiusip4'] = $_POST['radiusip4']; else unset($newcp['radiusip4']); $newcp['radiusport'] = $_POST['radiusport']; $newcp['radiusport2'] = $_POST['radiusport2']; if (isset($_POST['radiusport3'])) $newcp['radiusport3'] = $_POST['radiusport3']; if (isset($_POST['radiusport4'])) $newcp['radiusport4'] = $_POST['radiusport4']; $newcp['radiusacctport'] = $_POST['radiusacctport']; $newcp['radiuskey'] = $_POST['radiuskey']; $newcp['radiuskey2'] = $_POST['radiuskey2']; $newcp['radiuskey3'] = $_POST['radiuskey3']; $newcp['radiuskey4'] = $_POST['radiuskey4']; $newcp['radiusvendor'] = $_POST['radiusvendor'] ? $_POST['radiusvendor'] : false; $newcp['radiussession_timeout'] = $_POST['radiussession_timeout'] ? true : false; $newcp['radiussrcip_attribute'] = $_POST['radiussrcip_attribute']; $newcp['passthrumacadd'] = $_POST['passthrumacadd'] ? true : false; $newcp['passthrumacaddusername'] = $_POST['passthrumacaddusername'] ? true : false; $newcp['radmac_format'] = $_POST['radmac_format'] ? $_POST['radmac_format'] : false; if (!is_array($newcp['page'])) $newcp['page'] = array(); /* file upload? */ if (is_uploaded_file($_FILES['htmlfile']['tmp_name'])) $newcp['page']['htmltext'] = base64_encode(file_get_contents($_FILES['htmlfile']['tmp_name'])); if (is_uploaded_file($_FILES['errfile']['tmp_name'])) $newcp['page']['errtext'] = base64_encode(file_get_contents($_FILES['errfile']['tmp_name'])); if (is_uploaded_file($_FILES['logoutfile']['tmp_name'])) $newcp['page']['logouttext'] = base64_encode(file_get_contents($_FILES['logoutfile']['tmp_name'])); write_config(); captiveportal_configure_zone($newcp); filter_configure(); header("Location: services_captiveportal_zones.php"); exit; } else { if (is_array($_POST['cinterface'])) $pconfig['cinterface'] = implode(",", $_POST['cinterface']); } } include("head.inc"); ?>
  onClick="enable_change(false)">





>
>


>
>
>


>
>


>
>
> /
>
   
>
>
>
>
   
   
Primary Authentication Source


  

  
Secondary Authentication Source

  

  
 
  >

  >
>
>
>
  >

>



00:11:22:33:44:55
001122-334455
00-11-22-33-44-55
0011.2233.4455
001122334455
>


Create one under System > Cert Manager.





<form method="post" action="$PORTAL_ACTION$">
   <input name="auth_user" type="text">
   <input name="auth_pass" type="password">
   <input name="auth_voucher" type="text">
   <input name="redirurl" type="hidden" value="$PORTAL_REDIRURL$">
   <input name="accept" type="submit" value="Continue">
</form>





"$PORTAL_MESSAGE$",





  "; ?> " onClick="enable_change(true)"> " onClick="enable_change(true)">