chore: log full source hostname
This commit is contained in:
@@ -15,7 +15,7 @@ return static function (): void {
|
|||||||
$auditBase = [
|
$auditBase = [
|
||||||
'request_id' => bin2hex(random_bytes(8)),
|
'request_id' => bin2hex(random_bytes(8)),
|
||||||
'source_host' => $ctx->sourceHost(),
|
'source_host' => $ctx->sourceHost(),
|
||||||
'server_name' => $ctx->serverName(),
|
'server_name' => $ctx->auditServerName(),
|
||||||
'target_host' => $settings->targetBaseUrl(),
|
'target_host' => $settings->targetBaseUrl(),
|
||||||
'username' => $ctx->username(),
|
'username' => $ctx->username(),
|
||||||
'ttl' => $settings->loginKeyTtl(),
|
'ttl' => $settings->loginKeyTtl(),
|
||||||
|
|||||||
@@ -57,6 +57,11 @@ final class DirectAdminContext
|
|||||||
return $this->serverName;
|
return $this->serverName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function auditServerName(): string
|
||||||
|
{
|
||||||
|
return $this->sourceHost;
|
||||||
|
}
|
||||||
|
|
||||||
public function method(): string
|
public function method(): string
|
||||||
{
|
{
|
||||||
return $this->method;
|
return $this->method;
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ final class Settings
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'DEFAULT_ENABLE' => 'true',
|
'DEFAULT_ENABLE' => 'true',
|
||||||
'MAIL_LOGIN_TARGET_NAME' => 'mx1',
|
|
||||||
'MAIL_LOGIN_TARGET_BASE_URL' => 'https://mx1.mojserwer.pl:2222',
|
'MAIL_LOGIN_TARGET_BASE_URL' => 'https://mx1.mojserwer.pl:2222',
|
||||||
'MAIL_LOGIN_REDIRECT_URL' => '/',
|
'MAIL_LOGIN_REDIRECT_URL' => '/',
|
||||||
'LOGIN_KEY_TTL' => '14400',
|
'LOGIN_KEY_TTL' => '14400',
|
||||||
|
|||||||
@@ -8,8 +8,7 @@ DEFAULT_ENABLE=true
|
|||||||
# Login URL jest tworzony wyłącznie przez direct SSH command:
|
# 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.
|
# 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.
|
# Adres docelowego panelu poczty.
|
||||||
MAIL_LOGIN_TARGET_NAME=mx1
|
|
||||||
MAIL_LOGIN_TARGET_BASE_URL=https://mx1.mojserwer.pl:2222
|
MAIL_LOGIN_TARGET_BASE_URL=https://mx1.mojserwer.pl:2222
|
||||||
MAIL_LOGIN_REDIRECT_URL=/
|
MAIL_LOGIN_REDIRECT_URL=/
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@ name=MX-Autologin
|
|||||||
id=mxautologin
|
id=mxautologin
|
||||||
type=user
|
type=user
|
||||||
author=HITME.PL
|
author=HITME.PL
|
||||||
version=1.1.4
|
version=1.1.5
|
||||||
active=no
|
active=no
|
||||||
installed=no
|
installed=no
|
||||||
user_run_as=root
|
user_run_as=root
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ test('directadmin context derives server name from first host label', function (
|
|||||||
assert_same('mxtest', $ctx->username());
|
assert_same('mxtest', $ctx->username());
|
||||||
assert_same('h4.domena.pl', $ctx->sourceHost());
|
assert_same('h4.domena.pl', $ctx->sourceHost());
|
||||||
assert_same('h4', $ctx->serverName());
|
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 {
|
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.domena.pl', $ctx->sourceHost());
|
||||||
assert_same('h4', $ctx->serverName());
|
assert_same('h4', $ctx->serverName());
|
||||||
|
assert_same('h4.domena.pl', $ctx->auditServerName());
|
||||||
});
|
});
|
||||||
|
|
||||||
test('directadmin context fails closed without directadmin username', function (): void {
|
test('directadmin context fails closed without directadmin username', function (): void {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ test('plugin metadata and packaging docs match project rules', function (): void
|
|||||||
assert_contains('name=MX-Autologin', $conf);
|
assert_contains('name=MX-Autologin', $conf);
|
||||||
assert_contains('id=mxautologin', $conf);
|
assert_contains('id=mxautologin', $conf);
|
||||||
assert_contains('type=user', $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('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/src', $packing);
|
||||||
assert_contains('/Users/marek/GPT/ChatGPT/da_plugins/mail-login/archives/X.Y.Z/mxautologin.tar.gz', $packing);
|
assert_contains('/Users/marek/GPT/ChatGPT/da_plugins/mail-login/archives/X.Y.Z/mxautologin.tar.gz', $packing);
|
||||||
|
|||||||
@@ -84,6 +84,14 @@ test('settings do not expose deprecated mail login method switch', function ():
|
|||||||
assert_not_contains('MAIL_LOGIN_METHOD', $config);
|
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 {
|
test('settings expose disabled plugin flag through access guard', function (): void {
|
||||||
$settings = Settings::fromArray(['DEFAULT_ENABLE' => 'false']);
|
$settings = Settings::fromArray(['DEFAULT_ENABLE' => 'false']);
|
||||||
assert_false($settings->defaultEnable());
|
assert_false($settings->defaultEnable());
|
||||||
|
|||||||
Reference in New Issue
Block a user