From 78a5e5f84e9b44c7d530b8bdc8da18972b97f46c Mon Sep 17 00:00:00 2001 From: Konstantin Kelemen Date: Thu, 26 Jun 2025 15:11:29 +0300 Subject: [PATCH 1/2] Add username to Deployment details page --- library/Director/Core/CoreApi.php | 10 ++++++++-- library/Director/Web/Widget/DeploymentInfo.php | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/library/Director/Core/CoreApi.php b/library/Director/Core/CoreApi.php index 88a2c7c68..384400849 100644 --- a/library/Director/Core/CoreApi.php +++ b/library/Director/Core/CoreApi.php @@ -3,6 +3,7 @@ namespace Icinga\Module\Director\Core; use Exception; +use Icinga\Authentication\Auth; use Icinga\Exception\NotFoundError; use Icinga\Module\Director\Db; use Icinga\Module\Director\Hook\DeploymentHook; @@ -834,6 +835,11 @@ public function dumpConfig(IcingaConfig $config, Db $db, $packageName = null) if ($packageName === null) { $packageName = $db->settings()->get('icinga_package_name'); } + $username = ''; + $auth = Auth::getInstance(); + if ($auth->isAuthenticated()) { + $username = $auth->getUser()->getUsername(); + } $start = microtime(true); /** @var DirectorDeploymentLog $deployment */ $deployment = DirectorDeploymentLog::create(array( @@ -842,9 +848,9 @@ public function dumpConfig(IcingaConfig $config, Db $db, $packageName = null) 'peer_identity' => $this->client->getPeerIdentity(), 'start_time' => date('Y-m-d H:i:s'), 'config_checksum' => $config->getChecksum(), - 'last_activity_checksum' => $config->getLastActivityChecksum() + 'last_activity_checksum' => $config->getLastActivityChecksum(), + 'username' => $username // 'triggered_by' => Util::getUsername(), - // 'username' => Util::getUsername(), // 'module_name' => $moduleName, )); diff --git a/library/Director/Web/Widget/DeploymentInfo.php b/library/Director/Web/Widget/DeploymentInfo.php index 14943bda8..2f27c2cbc 100644 --- a/library/Director/Web/Widget/DeploymentInfo.php +++ b/library/Director/Web/Widget/DeploymentInfo.php @@ -78,6 +78,7 @@ protected function createInfoTable() $table->addNameValuePairs([ $this->translate('Deployment time') => $dep->start_time, $this->translate('Sent to') => $dep->peer_identity, + $this->translate('Triggered by') => $dep->username, ]); if ($this->config !== null) { $table->addNameValuePairs([ From 94f48e1935d4a8e61ccbfc87615b971d14b629e2 Mon Sep 17 00:00:00 2001 From: Konstantin Kelemen Date: Thu, 26 Jun 2025 15:18:53 +0300 Subject: [PATCH 2/2] username variable improvement --- library/Director/Core/CoreApi.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Director/Core/CoreApi.php b/library/Director/Core/CoreApi.php index 384400849..383075ceb 100644 --- a/library/Director/Core/CoreApi.php +++ b/library/Director/Core/CoreApi.php @@ -835,7 +835,7 @@ public function dumpConfig(IcingaConfig $config, Db $db, $packageName = null) if ($packageName === null) { $packageName = $db->settings()->get('icinga_package_name'); } - $username = ''; + $username = null; $auth = Auth::getInstance(); if ($auth->isAuthenticated()) { $username = $auth->getUser()->getUsername();