17 lines
495 B
PHP
17 lines
495 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
final class SourceAuthorizer
|
|
{
|
|
public static function assertAllowed(string $sourceHost, Settings $settings): void
|
|
{
|
|
$allowed = $settings->allowedSourceHosts();
|
|
if ($allowed === []) {
|
|
throw new RuntimeException('No source host allowlist configured');
|
|
}
|
|
if (!in_array(Settings::normalizeHost($sourceHost), $allowed, true)) {
|
|
throw new RuntimeException('Source host is not allowed');
|
|
}
|
|
}
|
|
}
|