2026-05-05 10:29:54 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
|
*/
|
|
|
|
|
namespace OC\Core\Command\OCM;
|
|
|
|
|
|
|
|
|
|
use OC\Core\Command\Base;
|
|
|
|
|
use OC\OCM\OCMSignatoryManager;
|
|
|
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
|
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
|
|
|
|
|
|
class ActivateKey extends Base {
|
|
|
|
|
public function __construct(
|
|
|
|
|
private readonly OCMSignatoryManager $signatoryManager,
|
|
|
|
|
) {
|
|
|
|
|
parent::__construct();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[\Override]
|
|
|
|
|
protected function configure(): void {
|
|
|
|
|
$this
|
|
|
|
|
->setName('ocm:keys:activate')
|
2026-05-11 10:13:13 -04:00
|
|
|
->setDescription('promote the staged JWKS key to active; the previous active key moves to retiring');
|
2026-05-05 10:29:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[\Override]
|
|
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int {
|
|
|
|
|
try {
|
2026-05-11 10:13:13 -04:00
|
|
|
$this->signatoryManager->activateStagedJwksKey();
|
2026-05-05 10:29:54 -04:00
|
|
|
} catch (\RuntimeException $e) {
|
|
|
|
|
$output->writeln('<error>' . $e->getMessage() . '</error>');
|
2026-05-11 05:37:09 -04:00
|
|
|
return self::FAILURE;
|
2026-05-05 10:29:54 -04:00
|
|
|
}
|
|
|
|
|
$output->writeln('<info>Staged key promoted to active.</info>');
|
|
|
|
|
$output->writeln('Run <info>occ ocm:keys:retire</info> once any in-flight signatures using the previous key have been verified.');
|
2026-05-11 05:37:09 -04:00
|
|
|
return self::SUCCESS;
|
2026-05-05 10:29:54 -04:00
|
|
|
}
|
|
|
|
|
}
|