mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-04-08 18:55:09 +02:00
#13035 added sync jwt with nodes
This commit is contained in:
parent
1299e17ccc
commit
06947b0457
@ -7708,7 +7708,7 @@ UPDATE `twelcome_tip` SET url = 'https://pandorafms.com/manual/!current/start?id
|
||||
|
||||
DELETE FROM tconfig WHERE `token` = 'legacy_database_ha';
|
||||
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('JWT_signature', '');
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('JWT_signature', 1);
|
||||
DELETE FROM tconfig WHERE `token` = 'loginhash_pwd';
|
||||
|
||||
COMMIT;
|
@ -185,4 +185,30 @@ final class JWTRepository
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sync the signature with nodes for jwt.
|
||||
*
|
||||
* @param string|null $signature Signature to send nodes.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function syncSignatureWithNodes(?string $signature):void
|
||||
{
|
||||
global $config;
|
||||
if (function_exists('metaconsole_get_servers') === true) {
|
||||
$config['JWT_signature'] = -1;
|
||||
$servers = metaconsole_get_servers();
|
||||
foreach ($servers as $server) {
|
||||
if (metaconsole_connect($server) == NOERR) {
|
||||
config_update_value('JWT_signature', $signature, true);
|
||||
}
|
||||
|
||||
metaconsole_restore_db();
|
||||
}
|
||||
|
||||
$config['JWT_signature'] = $signature;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -185,6 +185,7 @@ if (session_status() === PHP_SESSION_NONE) {
|
||||
|
||||
config_process_config();
|
||||
config_prepare_session();
|
||||
config_prepare_jwt_signature();
|
||||
|
||||
if ((bool) $config['console_log_enabled'] === true) {
|
||||
error_reporting(E_ALL ^ E_NOTICE);
|
||||
|
@ -30,6 +30,7 @@
|
||||
// Config functions.
|
||||
require_once __DIR__.'/../vendor/autoload.php';
|
||||
require_once __DIR__.'/functions.php';
|
||||
require_once __DIR__.'/class/JWTRepository.class.php';
|
||||
enterprise_include_once('include/functions_config.php');
|
||||
|
||||
use PandoraFMS\Core\DBMaintainer;
|
||||
@ -4212,3 +4213,14 @@ function config_prepare_session()
|
||||
ini_set('post_max_size', $config['max_file_size']);
|
||||
ini_set('upload_max_filesize', $config['max_file_size']);
|
||||
}
|
||||
|
||||
|
||||
function config_prepare_jwt_signature()
|
||||
{
|
||||
global $config;
|
||||
if (is_metaconsole() === true && is_centralized() === true && $config['JWT_signature'] == 1) {
|
||||
$signature = JWTRepository::generateSignature();
|
||||
config_update_value('JWT_signature', $signature, true);
|
||||
JWTRepository::syncSignatureWithNodes($signature);
|
||||
}
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES
|
||||
('trap2agent', '0'),
|
||||
('date_format', 'F j, Y, g:i a'),
|
||||
('event_view_hr', 8),
|
||||
('JWT_signature', ''),
|
||||
('JWT_signature', 1),
|
||||
('trap2agent', 0),
|
||||
('prominent_time', 'comparation'),
|
||||
('timesource', 'system'),
|
||||
|
Loading…
x
Reference in New Issue
Block a user