chore: log full source hostname

This commit is contained in:
Marek Miklewicz
2026-06-30 21:35:12 +02:00
parent b6a9180eae
commit 311190a7cd
8 changed files with 19 additions and 6 deletions
+1 -1
View File
@@ -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(),
+5
View File
@@ -57,6 +57,11 @@ final class DirectAdminContext
return $this->serverName;
}
public function auditServerName(): string
{
return $this->sourceHost;
}
public function method(): string
{
return $this->method;
-1
View File
@@ -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',
+1 -2
View File
@@ -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=/
+1 -1
View File
@@ -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
+2
View File
@@ -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 {
+1 -1
View File
@@ -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);
+8
View File
@@ -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());