refactor: remove source host allowlist from direct login

This commit is contained in:
Marek Miklewicz
2026-06-30 15:25:54 +02:00
parent b27c5c774a
commit c115b2861d
10 changed files with 11 additions and 83 deletions
+2 -11
View File
@@ -20,7 +20,7 @@ final class DirectAdminContext
if (!preg_match('/^[A-Za-z0-9][A-Za-z0-9._-]{0,31}$/', $username)) {
throw new InvalidArgumentException('Invalid DirectAdmin username');
}
$host = self::trustedSourceHost($server, $settings);
$host = self::trustedSourceHost($server);
if ($host === '') {
throw new InvalidArgumentException('Missing source host');
}
@@ -37,17 +37,8 @@ final class DirectAdminContext
/**
* @param array<string,mixed> $server
*/
private static function trustedSourceHost(array $server, Settings $settings): string
private static function trustedSourceHost(array $server): string
{
$configuredName = $settings->sourceServerName();
if ($configuredName !== '') {
foreach ($settings->allowedSourceHosts() as $allowedHost) {
$label = $settings->sanitizeServerName(explode('.', $allowedHost)[0] ?? '');
if ($label === $configuredName) {
return $allowedHost;
}
}
}
return Settings::normalizeHost((string)($server['SERVER_NAME'] ?? ''));
}