Example #1
0
 protected function createUser($username, $role)
 {
     global $AUTH;
     $AUTH->createUser($username, time() * rand(1, 10));
     if ($role !== '') {
         $A = new CoreAuthorisationHandler();
         $A->parsePermissions();
         $A->updateUserRoles($A->getUserId($username), array($A->getRoleId($role)));
     }
 }
Example #2
0
 private function parseMapJson($objectId, $mapName, $what)
 {
     global $AUTHORISATION;
     // Check if the user is permitted to view this
     if (!$AUTHORISATION->isPermitted('Map', 'view', $mapName)) {
         return null;
     }
     // If the parameter filterUser is set, filter the maps by the username
     // given in this parameter. This is a mechanism to be authed as generic
     // user but see the maps of another user. This feature is disabled by
     // default but could be enabled if you need it.
     if (cfg('global', 'user_filtering') && isset($_GET['filterUser']) && $_GET['filterUser'] != '') {
         $AUTHORISATION2 = new CoreAuthorisationHandler();
         $AUTHORISATION2->parsePermissions($_GET['filterUser']);
         if (!$AUTHORISATION2->isPermitted('Map', 'view', $mapName)) {
             return null;
         }
         // Switch the auth cookie to this user
         global $SHANDLER;
         $SHANDLER->aquire();
         $SHANDLER->set('authCredentials', array('user' => $_GET['filterUser'], 'password' => ''));
         $SHANDLER->set('authTrusted', true);
         $SHANDLER->commit();
     }
     $map = array('object_id' => $objectId);
     $MAPCFG = new GlobalMapCfg($mapName);
     $MAPCFG->checkMapConfigExists(true);
     $MAPCFG->readMapConfig();
     // Only perform this check with a valid config
     if ($MAPCFG->getValue(0, 'show_in_lists') != 1) {
         return null;
     }
     $MAP = new NagVisMap($MAPCFG, GET_STATE, !IS_VIEW);
     // Apply overview related configuration to object
     $MAP->MAPOBJ->setConfiguration($this->getMapDefaultOpts($mapName, $MAPCFG->getAlias()));
     if ($MAP->MAPOBJ->checkMaintenance(0)) {
         $map['overview_url'] = $this->htmlBase . '/index.php?mod=Map&act=view&show=' . $mapName;
         $map['overview_class'] = '';
     } else {
         $map['overview_class'] = 'disabled';
         $map['overview_url'] = 'javascript:alert(\'' . l('The map is in maintenance mode. Please be patient.') . '\');';
         $map['summary_output'] = l('The map is in maintenance mode. Please be patient.');
         $MAP->MAPOBJ->clearMembers();
         $MAP->MAPOBJ->setSummaryState('UNKNOWN');
         $MAP->MAPOBJ->fetchIcon();
     }
     if (cfg('index', 'showmapthumbs') == 1) {
         $map['overview_image'] = $this->renderMapThumb($MAPCFG);
     }
     return array($MAP->MAPOBJ, $map);
 }
Example #3
0
$AUTH = new CoreAuthHandler();
if ($AUTH->checkUserExists($userCentreon)) {
    $credential = array('user' => $userCentreon);
    $AUTH->setTrustUsername(true);
    $AUTH->setLogoutPossible(true);
    $AUTH->passCredentials($credential);
    $_SESSION['logonModule'] = cfg('global', 'logonmodule');
    $_SESSION['authModule'] = $AUTH->getModule();
    $_SESSION['authCredentials'] = $credential;
    $_SESSION['authTrusted'] = $AUTH->authedTrusted();
    $_SESSION['authLogoutPossible'] = $AUTH->logoutSupported();
    if ($single_nagvis_user) {
        $listMap = $core->getAvailableMaps();
    } else {
        if ($AUTH->isAuthenticated()) {
            $AUTHORISATION = new CoreAuthorisationHandler();
            $AUTHORISATION->parsePermissions();
            $core->setAA($AUTH, $AUTHORISATION);
            $list = array();
            $maps = $core->getAvailableMaps();
            foreach ($maps as $key => $val) {
                if ($core->getAuthorization()->isPermitted('Map', 'view', $val)) {
                    $list[$key] = $val;
                }
            }
            if (empty($list)) {
                $error = _("No map available");
            } else {
                $listMap = $list;
            }
        } else {
Example #4
0
    $logonModule = $logonModule == 'CoreLogonDialog' ? 'CoreLogonDialogHandler' : $logonModule;
    $MODULE = new $logonModule($CORE);
    $ret = $MODULE->check();
    // Maybe handle other module now
    if (is_array($ret)) {
        $UHANDLER->set('mod', $ret[0]);
        $UHANDLER->set('act', $ret[1]);
        $LOGIN_MSG = $ret[2];
    }
}
/*
* Authorisation 1: Collect and save the permissions when the user is logged in
*                  and nothing other is saved yet
*/
if ($AUTH->isAuthenticated()) {
    $AUTHORISATION = new CoreAuthorisationHandler();
    $AUTHORISATION->parsePermissions();
} else {
    $AUTHORISATION = null;
}
// Make the AA information available to whole NagVis for permission checks
$CORE->setAA($AUTH, $AUTHORISATION);
// Re-set the language to handle the user individual language
$_LANG->setLanguage(HANDLE_USERCFG);
/*
* Module handling 1: Choose modules
*/
// Register valid modules
// Unregistered modules can not be accessed
foreach ($_modules as $mod) {
    $MHANDLER->regModule($mod);
Example #5
0
 public function getPermittedMaps()
 {
     global $AUTHORISATION;
     $list = array();
     foreach ($this->getAvailableMaps() as $mapName) {
         // Check if the user is permitted to view this
         if (!$AUTHORISATION->isPermitted('Map', 'view', $mapName)) {
             continue;
         }
         // If the parameter filterUser is set, filter the maps by the username
         // given in this parameter. This is a mechanism to be authed as generic
         // user but see the maps of another user. This feature is disabled by
         // default but could be enabled if you need it.
         if (cfg('global', 'user_filtering') && isset($_GET['filterUser']) && $_GET['filterUser'] != '') {
             $AUTHORISATION2 = new CoreAuthorisationHandler();
             $AUTHORISATION2->parsePermissions($_GET['filterUser']);
             if (!$AUTHORISATION2->isPermitted('Map', 'view', $mapName)) {
                 continue;
             }
             // Switch the auth cookie to this user
             global $SHANDLER;
             $SHANDLER->aquire();
             $SHANDLER->set('authCredentials', array('user' => $_GET['filterUser'], 'password' => ''));
             $SHANDLER->set('authTrusted', true);
             $SHANDLER->commit();
         }
         $list[$mapName] = $mapName;
     }
     return $list;
 }