mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-25 18:45:27 -06:00
Created command to generate a random secret key string
This commit is contained in:
parent
2a089f05b1
commit
57bc681b9e
@ -11,6 +11,7 @@ return [
|
|||||||
Command\GetVisitsCommand::class,
|
Command\GetVisitsCommand::class,
|
||||||
Command\ProcessVisitsCommand::class,
|
Command\ProcessVisitsCommand::class,
|
||||||
Command\Config\GenerateCharsetCommand::class,
|
Command\Config\GenerateCharsetCommand::class,
|
||||||
|
Command\Config\GenerateSecretCommand::class,
|
||||||
Command\Api\GenerateKeyCommand::class,
|
Command\Api\GenerateKeyCommand::class,
|
||||||
Command\Api\DisableKeyCommand::class,
|
Command\Api\DisableKeyCommand::class,
|
||||||
Command\Api\ListKeysCommand::class,
|
Command\Api\ListKeysCommand::class,
|
||||||
|
@ -17,6 +17,7 @@ return [
|
|||||||
Command\ProcessVisitsCommand::class => AnnotatedFactory::class,
|
Command\ProcessVisitsCommand::class => AnnotatedFactory::class,
|
||||||
Command\ProcessVisitsCommand::class => AnnotatedFactory::class,
|
Command\ProcessVisitsCommand::class => AnnotatedFactory::class,
|
||||||
Command\Config\GenerateCharsetCommand::class => AnnotatedFactory::class,
|
Command\Config\GenerateCharsetCommand::class => AnnotatedFactory::class,
|
||||||
|
Command\Config\GenerateSecretCommand::class => AnnotatedFactory::class,
|
||||||
Command\Api\GenerateKeyCommand::class => AnnotatedFactory::class,
|
Command\Api\GenerateKeyCommand::class => AnnotatedFactory::class,
|
||||||
Command\Api\DisableKeyCommand::class => AnnotatedFactory::class,
|
Command\Api\DisableKeyCommand::class => AnnotatedFactory::class,
|
||||||
Command\Api\ListKeysCommand::class => AnnotatedFactory::class,
|
Command\Api\ListKeysCommand::class => AnnotatedFactory::class,
|
||||||
|
45
module/CLI/src/Command/Config/GenerateSecretCommand.php
Normal file
45
module/CLI/src/Command/Config/GenerateSecretCommand.php
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
namespace Shlinkio\Shlink\CLI\Command\Config;
|
||||||
|
|
||||||
|
use Acelaya\ZsmAnnotatedServices\Annotation\Inject;
|
||||||
|
use Shlinkio\Shlink\Common\Util\StringUtilsTrait;
|
||||||
|
use Symfony\Component\Console\Command\Command;
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Zend\I18n\Translator\TranslatorInterface;
|
||||||
|
|
||||||
|
class GenerateSecretCommand extends Command
|
||||||
|
{
|
||||||
|
use StringUtilsTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var TranslatorInterface
|
||||||
|
*/
|
||||||
|
private $translator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GenerateCharsetCommand constructor.
|
||||||
|
* @param TranslatorInterface $translator
|
||||||
|
*
|
||||||
|
* @Inject({"translator"})
|
||||||
|
*/
|
||||||
|
public function __construct(TranslatorInterface $translator)
|
||||||
|
{
|
||||||
|
$this->translator = $translator;
|
||||||
|
parent::__construct(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function configure()
|
||||||
|
{
|
||||||
|
$this->setName('config:generate-secret')
|
||||||
|
->setDescription($this->translator->translate(
|
||||||
|
'Generates a random secret string that can be used for JWT token encryption'
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function execute(InputInterface $input, OutputInterface $output)
|
||||||
|
{
|
||||||
|
$secret = $this->generateRandomString(32);
|
||||||
|
$output->writeln($this->translator->translate('Secret key:') . sprintf(' <info>%s</info>', $secret));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user