Module: nagvis Branch: master Commit: d8e79bf16287f2615d2e4624a2b544dbebe581e9 URL: http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis;a=commit;h=d8e79bf16287f2615d2e4624a2b544dbebe581e9
Author: LaMi <[email protected]> Date: Fri Dec 4 21:44:57 2009 +0100 Removed old file auth --- etc/users.ini.php-sample | 24 ----- share/server/core/classes/CoreAuthModFile.php | 105 -------------------- .../core/classes/CoreAuthorisationModFile.php | 73 -------------- 3 files changed, 0 insertions(+), 202 deletions(-) diff --git a/etc/users.ini.php-sample b/etc/users.ini.php-sample deleted file mode 100644 index a5004f4..0000000 --- a/etc/users.ini.php-sample +++ /dev/null @@ -1,24 +0,0 @@ -; <?php return 1; ?> -; The line above is to prevent viewing this file from web -; DON'T REMOVE IT! - -; ---------------------------- -; Default NagVis user authentication file -; This file is only being used when using the file authentication module -; ---------------------------- -; !!! The sections/variables with a leading ";" won't be recognized by NagVis (commented out) !!! -; ---------------------------- - -; Sample user definition -; The username needs to be set in the section name -[nagiosadmin] -; The userId needs to be a uniq ID -userId=1 -; The password is an sha1 encoded string -password="7f09c620da83db16ef9b69abfb8edd6b849d2d2b" -; Each user needs to have one or more roles to be able to access NagVis -roles="Administrators,Users" - -; ------------------------- -; EOF -; ------------------------- diff --git a/share/server/core/classes/CoreAuthModFile.php b/share/server/core/classes/CoreAuthModFile.php deleted file mode 100644 index b46e786..0000000 --- a/share/server/core/classes/CoreAuthModFile.php +++ /dev/null @@ -1,105 +0,0 @@ -<?php -/******************************************************************************* - * - * CoreAuthModFile.php - Authentication module for file based authentication - * - * Copyright (c) 2004-2009 NagVis Project (Contact: [email protected]) - * - * License: - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - ******************************************************************************/ - -/** - * @author Lars Michelsen <[email protected]> - */ -class CoreAuthModFile extends CoreAuthModule { - private $CORE; - private $USERCFG; - - private $iUserId = -1; - private $sUsername = ''; - private $sPassword = ''; - private $sPasswordHash = ''; - - public function __construct(GlobalCore $CORE) { - $this->CORE = $CORE; - - $this->USERCFG = new GlobalUserCfg($this->CORE, CONST_USERCFG); - } - - public function passCredentials($aData) { - if(isset($aData['user'])) { - $this->sUsername = $aData['user']; - } - if(isset($aData['password'])) { - $this->sPassword = $aData['password']; - } - if(isset($aData['passwordHash'])) { - $this->sPasswordHash = $aData['passwordHash']; - } - } - - public function getCredentials() { - return Array('user' => $this->sUsername, - 'passwordHash' => $this->sPasswordHash, - 'userId' => $this->iUserId); - } - - public function isAuthenticated() { - $bReturn = false; - - $aUsers = $this->USERCFG->getUsers(); - - // Only handle known users with password set and not empty pas sword - if($this->sUsername !== '' && isset($aUsers[$this->sUsername]) && $this->USERCFG->getValue($this->sUsername, 'password') !== null && $this->USERCFG->getValue($this->sUsername, 'password') !== '') { - - // Try to calculate the passowrd hash only when no hash is known at - // this time. For example when the user just entered the password - // for logging in. If the user is already logged in and this is just - // a session check don't try to rehash the password. - if($this->sPasswordHash === '') { - // Compose the password hash for comparing with the stored hash - $this->sPasswordHash = sha1(AUTH_PASSWORD_SALT.$this->sPassword); - } - - // Check the password hash - if($this->sPasswordHash === $this->USERCFG->getValue($this->sUsername, 'password')) { - // Set the user id on success - $this->iUserId = (integer) $this->USERCFG->getValue($this->sUsername, 'userId'); - - //FIXME: Logging? Successfull authentication - $bReturn = true; - } else { - //FIXME: Logging? Invalid password - $bReturn = false; - } - } else { - //FIXME: Logging? Invalid user - $bReturn = false; - } - - return $bReturn; - } - - public function getUser() { - return $this->sUsername; - } - - public function getUserId() { - return $this->iUserId; - } -} -?> diff --git a/share/server/core/classes/CoreAuthorisationModFile.php b/share/server/core/classes/CoreAuthorisationModFile.php deleted file mode 100644 index cd19489..0000000 --- a/share/server/core/classes/CoreAuthorisationModFile.php +++ /dev/null @@ -1,73 +0,0 @@ -<?php -/******************************************************************************* - * - * CoreAuthorisationModFile.php - Authorsiation module based on simple files - * - * Copyright (c) 2004-2009 NagVis Project (Contact: [email protected]) - * - * License: - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - ******************************************************************************/ - -/** - * @author Lars Michelsen <[email protected]> - */ -class CoreAuthorisationModFile extends CoreAuthorisationModule { - private $AUTHENTICATION; - private $CORE; - private $USERCFG; - - public function __construct(GlobalCore $CORE, CoreAuthHandler $AUTHENTICATION) { - $this->AUTHENTICATION = $AUTHENTICATION; - $this->CORE = $CORE; - - $this->USERCFG = new GlobalUserCfg($this->CORE, CONST_USERCFG); - } - - public function parsePermissions() { - $aPerms = Array(); - - $sUsername = $this->AUTHENTICATION->getUser(); - $aUsers = $this->USERCFG->getUsers(); - - // Only handle known users - if( - // User is valid - isset($aUsers[$sUsername]) - // User has roles - && $this->USERCFG->getValue($sUsername, 'roles') !== null && is_array($this->USERCFG->getValue($sUsername, 'roles')) - ) { - - // Get all the roles of the user - $aRoles = $this->USERCFG->getValue($sUsername, 'roles'); - - // Get all the permissions of the available roles - // FIXME: Authorisation parsing - //$aRolePerms = $this->CONF->get('authorisationRoles'); - - // Loop all users roles to merge the permissions - /*foreach($aRoles AS $sRole) { - if(isset($aRolePerms[$sRole]) && is_array($aRolePerms[$sRole])) { - $aPerms = array_merge_recursive($aPerms, $aRolePerms[$sRole]); - } - }*/ - $aPerms['*']['*'] = ''; - } - - return $aPerms; - } -} -?> ------------------------------------------------------------------------------ Join us December 9, 2009 for the Red Hat Virtual Experience, a free event focused on virtualization and cloud computing. Attend in-depth sessions from your desk. Your couch. Anywhere. http://p.sf.net/sfu/redhat-sfdev2dev _______________________________________________ Nagvis-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/nagvis-checkins
