feat: add configurable HLS CORS allowlists

This commit is contained in:
root
2026-09-04 22:28:33 +02:00
parent 6fae6a3a43
commit 9710e8d228
24 changed files with 879 additions and 7 deletions
+41
View File
@@ -0,0 +1,41 @@
<?php
declare(strict_types=1);
namespace Plugin\AzuraCastOnDemandHls\Command;
use InvalidArgumentException;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
#[AsCommand(name: 'azuracast:ondemand-hls:cors:add', description: 'Add one allowed cross-site HLS origin for a station.')]
final class AddCorsOriginCommand extends AbstractCorsCommand
{
protected function configure(): void
{
$this->configureStationArgument();
$this->addArgument('origin', InputArgument::REQUIRED, 'An HTTP(S) origin.');
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
$station = $this->findStation($input, $io);
if (null === $station) {
return self::FAILURE;
}
try {
$origins = $this->corsConfiguration->addAllowedOrigin($station->id, (string)$input->getArgument('origin'));
$this->reloadNginx($station, $io);
$io->success('Allowed HLS CORS origin added.');
$this->renderOrigins($io, $origins);
return self::SUCCESS;
} catch (InvalidArgumentException $exception) {
$io->error($exception->getMessage());
return self::INVALID;
}
}
}