Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Clean(platform): Clean appKey method and usage 22.04.x #11452

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions src/CentreonRemote/Application/Webservice/CentreonRemoteServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,6 @@ public function postAddToWaitList(): string
throw new \RestBadRequestException('Can not access your address.');
}

if (
!isset($_POST['app_key'])
|| !$_POST['app_key']
|| empty($appKey = filter_var($_POST['app_key'], FILTER_SANITIZE_STRING))
) {
throw new \RestBadRequestException('Please send \'app_key\' in the request.');
}

if (
!isset($_POST['version'])
|| !$_POST['version']
Expand Down Expand Up @@ -147,15 +139,14 @@ public function postAddToWaitList(): string
}

$createdAt = date('Y-m-d H:i:s');
$insertQuery = "INSERT INTO `remote_servers` (`ip`, `app_key`, `version`, `is_connected`,
$insertQuery = "INSERT INTO `remote_servers` (`ip`, `version`, `is_connected`,
`created_at`, `http_method`, `http_port`, `no_check_certificate`)
VALUES (:ip, :app_key, :version, 0, '{$createdAt}',
VALUES (:ip, :version, 0, '{$createdAt}',
:http_method, :http_port, :no_check_certificate
)";

$insert = $this->pearDB->prepare($insertQuery);
$insert->bindValue(':ip', $ip, \PDO::PARAM_STR);
$insert->bindValue(':app_key', $appKey, \PDO::PARAM_STR);
$insert->bindValue(':version', $version, \PDO::PARAM_STR);
$insert->bindValue(':http_method', $httpScheme, \PDO::PARAM_STR);
$insert->bindValue(':http_port', $httpPort, \PDO::PARAM_INT);
Expand Down
9 changes: 0 additions & 9 deletions src/CentreonRemote/Domain/Service/NotifyMasterService.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,10 @@ public function pingMaster($ip, $data, $noCheckCertificate = false, $noProxy = f

$url = "{$ip}/centreon/api/external.php?object=centreon_remote_server&action=addToWaitList";
$repository = $this->dbManager->getRepository(InformationsRepository::class);
$applicationKey = $repository->getOneByKey('appKey');
$version = $repository->getOneByKey('version');

if (empty($applicationKey)) {
return [
'status' => self::FAIL,
'details' => self::NO_APP_KEY
];
}

try {
$curlData = [
'app_key' => $applicationKey->getValue(),
'version' => $version->getValue(),
'http_method' => $data['remoteHttpMethod'] ?? 'http',
'http_port' => $data['remoteHttpPort'] ?? '',
Expand Down
1 change: 0 additions & 1 deletion www/install/createTables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2321,7 +2321,6 @@ CREATE TABLE IF NOT EXISTS contact_feature (
CREATE TABLE IF NOT EXISTS `remote_servers` (
`id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`ip` VARCHAR(255) NOT NULL,
`app_key` VARCHAR(40) NOT NULL,
`version` VARCHAR(16) NOT NULL,
`is_connected` TINYINT(1) NOT NULL DEFAULT 0,
`created_at` TIMESTAMP NOT NULL,
Expand Down
2 changes: 0 additions & 2 deletions www/install/steps/process/insertBaseConf.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,7 @@
$link->exec("INSERT INTO `options` (`key`, `value`) VALUES ('gmt','" . $timezoneId . "')");

# Generate random key for this instance and set it to be not central and not remote
$uniqueKey = md5(uniqid(rand(), true));
$informationsTableInsert = "INSERT INTO `informations` (`key`,`value`) VALUES
('appKey', '{$uniqueKey}'),
('isRemote', 'no'),
('isCentral', 'yes')";

Expand Down