Security:
- Add SecurityHeadersListener (X-Content-Type-Options, X-Frame-Options,
CSP, Referrer-Policy, HSTS)
- Replace document.write() with document.documentElement.innerHTML
in login JS to avoid CSP violations
- Add CSS escaping (|e('css')) to env color values in _style.html.twig
- Document CSRF protection model: nonce serves as CSRF token for POST
form path (single-use, server-generated, 120s TTL)
- Reduce TOTP verification window from 10 periods (±5 min) to 1 (±30s)
- Remove hardcoded APP_SECRET from bin/franken.sh (now uses env or
generates random)
- Remove backup code values from debug log output
- Add .env to .gitignore
Bug fixes:
- Fix ->json access on possibly-null in LoginListener
(uses null-safe operator ?->)
- Fix validReturn() not checking false from parse_url (could cause
TypeError on malformed URLs)
- Add isHit() race condition check in AcceptListener and AllowListener
- Add try/finally in Kernel::terminate() so parent::terminate() always
runs even if persist() throws
- Add input validation to GenerateBackupCodesCommand (reject count < 1)
- Use Response::HTTP_INTERNAL_SERVER_ERROR constant in GetTotpTrait
instead of literal 500
Docker/CI:
- Explicitly install curl in Docker final image (needed for healthcheck)
- Update workflow tag pattern to v*.*.* (standardize on v-prefix)
- Extract version without v-prefix for Docker image tag
- Remove stale develop branch from CI triggers
- Fix publish.yaml git remote add to use set-url on re-runs
Code quality:
- Add declare(strict_types=1) to all interface files
- Add #[AsCommand] attribute to GenerateBackupCodesCommand
- Fix BackupCodeInterface default count to match implementation (10)
- Lowercase host before TLD lookup in DomainManager
- Expand TLD list with many missing multi-part TLDs (.com.au, .co.jp,
.com.br, .co.kr, .com.tw, .co.za, etc.) to prevent open redirect
vulnerabilities
- Disable unused Symfony sessions in framework.yaml
Tests:
- Update DomainManagerTest for corrected TLD parsing (.com.au, .co.jp,
.com.br now correctly recognized as multi-part)
- Update GetTotpTraitTest for corrected error message
- Update GenerateBackupCodesCommandTest: zero count now throws exception
52 lines
1.8 KiB
PHP
52 lines
1.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Command;
|
|
|
|
use App\PersistCache;
|
|
use App\Service\BackupCodeInterface;
|
|
use Psr\Cache\InvalidArgumentException;
|
|
use Symfony\Component\Console\Attribute\AsCommand;
|
|
use Symfony\Component\Console\Command\Command;
|
|
use Symfony\Component\Console\Input\InputArgument;
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
use Symfony\Component\Console\Exception\InvalidArgumentException as ConsoleInvalidArgumentException;
|
|
|
|
/** simple console command to generate backup codes
|
|
* usage: php bin/console app:generate-backup-codes [count] */
|
|
#[AsCommand(name: 'app:generate-backup-codes')]
|
|
final class GenerateBackupCodesCommand extends Command
|
|
{
|
|
public function __construct(
|
|
private readonly BackupCodeInterface $manager,
|
|
private readonly PersistCache $persistCache,
|
|
) {
|
|
parent::__construct();
|
|
}
|
|
|
|
protected function configure(): void
|
|
{
|
|
$this->setDescription('Generate single-use backup codes')
|
|
->addArgument('count', InputArgument::OPTIONAL, 'Number of codes to generate', 10);
|
|
}
|
|
|
|
/** @throws InvalidArgumentException */
|
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
|
{
|
|
/* since Kernel::terminate() does not get called, we must boot and persist explicitly */
|
|
$this->persistCache->boot();
|
|
$count = (int) $input->getArgument('count');
|
|
if ($count < 1) {
|
|
throw new ConsoleInvalidArgumentException('Count must be a positive integer.');
|
|
}
|
|
$codes = $this->manager->generate($count);
|
|
foreach ($codes as $code) {
|
|
$output->writeln($code);
|
|
}
|
|
$this->persistCache->persist();
|
|
return Command::SUCCESS;
|
|
}
|
|
}
|