All rights reserved. Based on m0n0wall (http://m0n0.ch/wall) Copyright (C) 2003-2006 Manuel Kasper . 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. */ /* ========================================================================== */ require_once("authng.inc"); /* Authenticate user - exit if failed (we should have a callback for this maybe) */ if (empty($authMethod)) { print "auth_method missing!\n"; } if (empty($backend)) { print "backing_method missing!\n"; } if (!$authMethod->authenticate($backend)) { exit; } /* scriptname is set in headjs.php if the user did try to access a page other * than index.php without beeing logged in. */ if (isset($_POST['scriptname']) && isSystemAdmin($HTTP_SERVER_VARS['AUTH_USER'])) { pfSenseHeader("{$_POST['scriptname']}"); exit; } $allowed = array(); // Once here, the user has authenticated with the web server. // Now, we give them access only to the appropriate pages for their group. if (!(isSystemAdmin($HTTP_SERVER_VARS['AUTH_USER']))) { $allowed[] = ''; if (isset($config['system']['group'][$groupindex[$config['system']['user'][$userindex[$HTTP_SERVER_VARS['AUTH_USER']]]['groupname']]]['pages'][0]['page'])) { $useridx = $userindex[$HTTP_SERVER_VARS['AUTH_USER']]; $grouidx = $groupindex[$config['system']['user'][$useridx]]; $allowed = &$config['system']['group'][$groupidx]['pages'][0]['page']; } $group = $config['system']['user'][$userindex[$HTTP_SERVER_VARS['AUTH_USER']]]['groupname']; /* get the group homepage, to be able to forward * the user to this particular PHP page. */ getGroupHomePage($group) == "" ? $home = "/index.php" : $home = "/" . getGroupHomePage($group); /* okay but if the user realy tries to explicitely access a particular * page, set $home to that page instead. */ if (isset($_POST['scriptname']) && $_POST['scriptname'] <> "/" && $_POST['scriptname'] <> "/index.php") $home = basename($_POST['scriptname']); // If the user is attempting to hit the default page, set it to specifically look for /index.php. // Without this, any user would have access to the index page. //if ($_SERVER['SCRIPT_NAME'] == '/') // $_SERVER['SCRIPT_NAME'] = $home; // Strip the leading / from the currently requested PHP page if (!in_array(basename($_SERVER['SCRIPT_NAME']),$allowed)) { // The currently logged in user is not allowed to access the page // they are attempting to go to. Redirect them to an allowed page. if(stristr($_SERVER['SCRIPT_NAME'],"sajax")) { echo "||Access to AJAX has been disallowed for this user."; exit; } if ($home <> "" && in_array($home, $allowed)) { pfSenseHeader("{$home}"); exit; } else { header("HTTP/1.0 401 Unauthorized"); header("Status: 401 Unauthorized"); echo display_error_form("401", "401 Unauthorized. Authorization required."); exit; } } if (isset($_SESSION['Logged_In'])) { /* * only forward if the user has just logged in * TODO: session auth based - may be an issue. */ if ($_SERVER['SCRIPT_NAME'] <> $home && empty($_SESSION['First_Visit'])) { $_SESSION['First_Visit'] = "False"; pfSenseHeader("{$home}"); exit; } } } function display_error_form($http_code, $desc) { global $g; $htmlstr = << An error occurred: {$http_code}

 

{$desc}

EOD; return $htmlstr; } function display_login_form() { require_once("globals.inc"); global $g; if(isAjax()) { if (isset($_POST['login'])) { if($_SESSION['Logged_In'] <> "True") { isset($_SESSION['Login_Error']) ? $login_error = $_SESSION['Login_Error'] : $login_error = "unknown reason"; echo "showajaxmessage('Invalid login ({$login_error}).');"; } if (file_exists("{$g['tmp_path']}/webconfigurator.lock")) { $whom = file_get_contents("{$g['tmp_path']}/webconfigurator.lock"); echo "showajaxmessage('This device is currently beeing maintained by: {$whom}.');"; } } exit; } ?> <?=gettext("Login"); ?>

 

:  

:  


" tabindex="3" />