refactor: remove source host allowlist from direct login
This commit is contained in:
@@ -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'] ?? ''));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user