private function handleResponseAuth()
 {
     $FHANDLER = new CoreRequestHandler(array_merge($_GET, $_POST));
     // Don't try to auth if one of the vars is missing
     if (!$FHANDLER->issetAndNotEmpty('_username') || !$FHANDLER->issetAndNotEmpty('_password')) {
         return null;
     }
     if (!$FHANDLER->match('_username', MATCH_USER_NAME) || $FHANDLER->isLongerThan('_username', AUTH_MAX_USERNAME_LENGTH)) {
         throw new FieldInputError('_username', l('Invalid username.'));
     }
     if (!$FHANDLER->issetAndNotEmpty('_password') || $FHANDLER->isLongerThan('_password', AUTH_MAX_PASSWORD_LENGTH)) {
         throw new FieldInputError('_password', l('Invalid password.'));
     }
     $a = array('user' => $FHANDLER->get('_username'), 'password' => $FHANDLER->get('_password'));
     // It is possible to only request onetime access to prevent getting added
     // and authentication cookie
     if (isset($_REQUEST['_onetime'])) {
         $a['onetime'] = true;
     }
     // Remove authentication infos. Hide it from the following code
     if (isset($_REQUEST['_username'])) {
         unset($_REQUEST['_username']);
     }
     if (isset($_REQUEST['_password'])) {
         unset($_REQUEST['_password']);
     }
     if (isset($_POST['_username'])) {
         unset($_POST['_username']);
     }
     if (isset($_POST['_password'])) {
         unset($_POST['_password']);
     }
     if (isset($_GET['_username'])) {
         unset($_GET['_username']);
     }
     if (isset($_GET['_password'])) {
         unset($_GET['_password']);
     }
     return $a;
 }
Example #2
0
 /**
  * Parses the information in html format
  *
  * @return	String 	String with Html Code
  * @author 	Lars Michelsen <*****@*****.**>
  */
 public function parse()
 {
     global $LOGIN_MSG, $_MAINCFG;
     // Initialize template system
     $TMPL = new FrontendTemplateSystem();
     $TMPLSYS = $TMPL->getTmplSys();
     $target = CoreRequestHandler::getRequestUri('');
     // Add the language to the target url when the user requested a specific language
     if (isset($_GET['lang']) && $_GET['lang'] != '' && strpos($target, 'lang=') === false) {
         if (strpos($target, '?') === false) {
             $target .= '?lang=' . $_GET['lang'];
         } else {
             $target .= '&lang=' . $_GET['lang'];
         }
     }
     $aData = array('generalProperties' => $_MAINCFG->parseGeneralProperties(), 'locales' => json_encode(array()), 'pageTitle' => cfg('internal', 'title') . ' &rsaquo; Log In', 'htmlBase' => cfg('paths', 'htmlbase'), 'htmlJs' => cfg('paths', 'htmljs'), 'htmlCss' => cfg('paths', 'htmlcss'), 'formTarget' => $target, 'htmlTemplates' => path('html', 'global', 'templates'), 'htmlImages' => cfg('paths', 'htmlimages'), 'maxPasswordLength' => AUTH_MAX_PASSWORD_LENGTH, 'maxUsernameLength' => AUTH_MAX_USERNAME_LENGTH, 'langName' => l('Name'), 'langPassword' => l('Password'), 'langLogin' => l('Login'), 'langTitleCookiesDisabled' => l('Cookies disabled'), 'langTextCookiesDisabled' => l('NagVis is unable to set a cookie in your browser. Please enable cookies for at least the NagVis host.'), 'loginMsg' => isset($LOGIN_MSG) && $LOGIN_MSG !== null ? $LOGIN_MSG->msg : '');
     // Build page based on the template file and the data array
     return $TMPLSYS->get($TMPL->getTmplFile(cfg('defaults', 'view_template'), 'login'), $aData);
 }
 public function handleAction()
 {
     global $AUTH;
     $sReturn = '';
     if ($this->offersAction($this->sAction)) {
         switch ($this->sAction) {
             case 'view':
                 // Check if user is already authenticated
                 if (!$AUTH->isAuthenticated()) {
                     $VIEW = new NagVisLoginView($this->CORE);
                     $sReturn = $VIEW->parse();
                 } else {
                     // When the user is already authenticated redirect to start page (overview)
                     Header('Location:' . CoreRequestHandler::getRequestUri(cfg('paths', 'htmlbase')));
                 }
                 break;
         }
     }
     return $sReturn;
 }
Example #4
0
 public function msgInvalidCredentials()
 {
     throw new NagVisException(l('You entered invalid credentials.'), l('Authentication failed'), 1, CoreRequestHandler::getReferer(''));
     return '';
 }
Example #5
0
 protected function handleResponseModifyObject()
 {
     $bValid = true;
     // Validate the response
     // Need to listen to POST and GET
     $aResponse = array_merge($_GET, $_POST);
     // FIXME: Maybe change all to POST
     $FHANDLER = new CoreRequestHandler($aResponse);
     // Check for needed params
     if ($bValid && !$FHANDLER->isSetAndNotEmpty('map')) {
         $bValid = false;
     }
     if ($bValid && !$FHANDLER->isSetAndNotEmpty('id')) {
         $bValid = false;
     }
     // All fields: Regex check
     if ($bValid && !$FHANDLER->match('map', MATCH_MAP_NAME)) {
         $bValid = false;
     }
     if ($bValid && $FHANDLER->isSetAndNotEmpty('id') && !$FHANDLER->match('id', MATCH_OBJECTID)) {
         $bValid = false;
     }
     if ($bValid) {
         $this->verifyMapExists($FHANDLER->get('map'));
     }
     // FIXME: Recode to FHANDLER
     $aOpts = $aResponse;
     // Remove the parameters which are not options of the object
     unset($aOpts['act']);
     unset($aOpts['mod']);
     unset($aOpts['map']);
     unset($aOpts['ref']);
     unset($aOpts['id']);
     unset($aOpts['lang']);
     // Also remove all "helper fields" which begin with a _
     foreach ($aOpts as $key => $val) {
         if (strpos($key, '_') === 0) {
             unset($aOpts[$key]);
         }
     }
     // Store response data
     if ($bValid === true) {
         // Return the data
         return array('map' => $FHANDLER->get('map'), 'id' => $FHANDLER->get('id'), 'refresh' => $FHANDLER->get('ref'), 'opts' => $aOpts);
     } else {
         return false;
     }
 }
 public function __construct($aOptions)
 {
     parent::__construct($aOptions);
 }