diff --git a/pandora_console/include/api.php b/pandora_console/include/api.php index b5f6d44ab7..0d105d5994 100644 --- a/pandora_console/include/api.php +++ b/pandora_console/include/api.php @@ -124,18 +124,22 @@ if (empty($apiPassword) === true ) { // Allow internal direct node -> metaconsole connection // or node -> own console connection. + $server_uid = get_parameter(('server_auth')); $config['__internal_call'] = true; - $config['id_usuario'] = 'admin'; + $config['id_usuario'] = $server_uid; // Compat. - $config['id_user'] = 'admin'; + $config['id_user'] = $server_uid; $correctLogin = true; + $config['is_admin'][$server_uid] = true; // Bypass credentials if server-auth and api-pass are correct. } else if (($config['server_unique_identifier'] === get_parameter('server_auth')) && ($api_password === $apiPassword) && ((bool) isInACL($ipOrigin) === true) ) { - $config['id_usuario'] = 'admin'; - $config['id_user'] = 'admin'; + $server_uid = get_parameter(('server_auth')); + $config['id_usuario'] = $server_uid; + $config['id_user'] = $server_uid; + $config['is_admin'][$server_uid] = true; $correctLogin = true; } else if ((bool) isInACL($ipOrigin) === true) { // External access. diff --git a/pandora_console/include/chart_generator.php b/pandora_console/include/chart_generator.php index 64a95b778d..529684569d 100644 --- a/pandora_console/include/chart_generator.php +++ b/pandora_console/include/chart_generator.php @@ -66,13 +66,34 @@ global $config; // Care whit this!!! check_login not working if you remove this. $config['id_user'] = $id_user; $_SESSION['id_usuario'] = $id_user; + +// Checks for server api req. +$bypassLogin = false; +if ($data_decoded['apipass'] !== null + && ($config['server_unique_identifier'] === $_SESSION['id_usuario']) +) { + $apiPassword = io_output_password( + db_get_value_filter( + 'value', + 'tconfig', + ['token' => 'api_password'] + ) + ); + + + if ($apiPassword === $data_decoded['apipass']) { + $bypassLogin = true; + } +} + if (!isset($config[$slicebar])) { $config[$slicebar] = $slicebar_value; } // Try to initialize session using existing php session id. $user = new PandoraFMS\User(['phpsessionid' => $session_id]); -if (check_login(false) === false) { + +if (check_login(false) === false && $bypassLogin !== true) { // Error handler. ?> diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 52409c14a6..d03b8d7412 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -4336,6 +4336,8 @@ function generator_chart_to_pdf( 'id_user' => $config['id_user'], 'slicebar' => $_SESSION['slicebar'], 'slicebar_value' => $config[$_SESSION['slicebar']], + 'apipass' => get_parameter('apipass', null), + ]; } else { $data = [ @@ -4345,6 +4347,7 @@ function generator_chart_to_pdf( 'id_user' => $config['id_user'], 'slicebar' => $_SESSION['slicebar'], 'slicebar_value' => $config[$_SESSION['slicebar']], + 'apipass' => get_parameter('apipass', null), ]; }