diff --git a/exec/handlers/login.php b/exec/handlers/login.php index deda10f..cbec46d 100644 --- a/exec/handlers/login.php +++ b/exec/handlers/login.php @@ -15,7 +15,7 @@ return static function (): void { $auditBase = [ 'request_id' => bin2hex(random_bytes(8)), 'source_host' => $ctx->sourceHost(), - 'server_name' => $ctx->serverName(), + 'server_name' => $ctx->auditServerName(), 'target_host' => $settings->targetBaseUrl(), 'username' => $ctx->username(), 'ttl' => $settings->loginKeyTtl(), diff --git a/exec/lib/DirectAdminContext.php b/exec/lib/DirectAdminContext.php index 6f43afa..20e5622 100644 --- a/exec/lib/DirectAdminContext.php +++ b/exec/lib/DirectAdminContext.php @@ -57,6 +57,11 @@ final class DirectAdminContext return $this->serverName; } + public function auditServerName(): string + { + return $this->sourceHost; + } + public function method(): string { return $this->method; diff --git a/exec/lib/Settings.php b/exec/lib/Settings.php index e520db9..115e20e 100644 --- a/exec/lib/Settings.php +++ b/exec/lib/Settings.php @@ -57,7 +57,6 @@ final class Settings { return [ 'DEFAULT_ENABLE' => 'true', - 'MAIL_LOGIN_TARGET_NAME' => 'mx1', 'MAIL_LOGIN_TARGET_BASE_URL' => 'https://mx1.mojserwer.pl:2222', 'MAIL_LOGIN_REDIRECT_URL' => '/', 'LOGIN_KEY_TTL' => '14400', diff --git a/plugin-settings.conf b/plugin-settings.conf index f98241c..6430be3 100644 --- a/plugin-settings.conf +++ b/plugin-settings.conf @@ -8,8 +8,7 @@ DEFAULT_ENABLE=true # Login URL jest tworzony wyłącznie przez direct SSH command: # serwer źródłowy łączy się po SSH do MX i uruchamia bezpośrednio /usr/bin/da login-url. -# Nazwa i adres docelowego panelu poczty. -MAIL_LOGIN_TARGET_NAME=mx1 +# Adres docelowego panelu poczty. MAIL_LOGIN_TARGET_BASE_URL=https://mx1.mojserwer.pl:2222 MAIL_LOGIN_REDIRECT_URL=/ diff --git a/plugin.conf b/plugin.conf index 547bffe..dd3085a 100644 --- a/plugin.conf +++ b/plugin.conf @@ -2,7 +2,7 @@ name=MX-Autologin id=mxautologin type=user author=HITME.PL -version=1.1.4 +version=1.1.5 active=no installed=no user_run_as=root diff --git a/tests/context_test.php b/tests/context_test.php index d97a74b..01003c5 100644 --- a/tests/context_test.php +++ b/tests/context_test.php @@ -19,6 +19,7 @@ test('directadmin context derives server name from first host label', function ( assert_same('mxtest', $ctx->username()); assert_same('h4.domena.pl', $ctx->sourceHost()); assert_same('h4', $ctx->serverName()); + assert_same('h4.domena.pl', $ctx->auditServerName()); }); test('directadmin context uses configured source server name and trusts local server name host', function (): void { @@ -33,6 +34,7 @@ test('directadmin context uses configured source server name and trusts local se assert_same('h4.domena.pl', $ctx->sourceHost()); assert_same('h4', $ctx->serverName()); + assert_same('h4.domena.pl', $ctx->auditServerName()); }); test('directadmin context fails closed without directadmin username', function (): void { diff --git a/tests/package_contents_test.php b/tests/package_contents_test.php index f3d1168..11d03ac 100644 --- a/tests/package_contents_test.php +++ b/tests/package_contents_test.php @@ -8,7 +8,7 @@ test('plugin metadata and packaging docs match project rules', function (): void assert_contains('name=MX-Autologin', $conf); assert_contains('id=mxautologin', $conf); assert_contains('type=user', $conf); - assert_contains('version=1.1.4', $conf); + assert_contains('version=1.1.5', $conf); assert_contains('user_run_as=root', $conf); assert_contains('/Users/marek/GPT/ChatGPT/da_plugins/mail-login/src', $packing); assert_contains('/Users/marek/GPT/ChatGPT/da_plugins/mail-login/archives/X.Y.Z/mxautologin.tar.gz', $packing); diff --git a/tests/settings_test.php b/tests/settings_test.php index cc90163..1b80886 100644 --- a/tests/settings_test.php +++ b/tests/settings_test.php @@ -84,6 +84,14 @@ test('settings do not expose deprecated mail login method switch', function (): assert_not_contains('MAIL_LOGIN_METHOD', $config); }); +test('settings do not expose cosmetic target name setting', function (): void { + $defaults = Settings::defaults(); + $config = file_get_contents(PLUGIN_ROOT . '/plugin-settings.conf') ?: ''; + + assert_false(array_key_exists('MAIL_LOGIN_TARGET_NAME', $defaults)); + assert_not_contains('MAIL_LOGIN_TARGET_NAME', $config); +}); + test('settings expose disabled plugin flag through access guard', function (): void { $settings = Settings::fromArray(['DEFAULT_ENABLE' => 'false']); assert_false($settings->defaultEnable());