Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ See [keep a changelog] for information about writing changes to this log.

## [Unreleased]

* Added support for Symfony 8

## [0.1.2]

* Fixed action to auto create github release
Expand Down Expand Up @@ -44,8 +46,8 @@ See [keep a changelog] for information about writing changes to this log.
* Basic bundle setup.

[keep a changelog]: https://keepachangelog.com/en/1.1.0/
[Unreleased]: https://github.com/itk-dev/vault-bundle/compare/0.1.0...head
[0.1.1]: https://github.com/itk-dev/vault-library/compare/0.1.1...0.1.2
[Unreleased]: https://github.com/itk-dev/vault-bundle/compare/0.1.2...head
[0.1.2]: https://github.com/itk-dev/vault-library/compare/0.1.1...0.1.2
[0.1.1]: https://github.com/itk-dev/vault-library/compare/0.1.0...0.1.1
[0.1.0]: https://github.com/itk-dev/vault-library/compare/0.0.4...0.1.0
[0.0.4]: https://github.com/itk-dev/vault-library/compare/0.0.3...0.0.4
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ retrieval of secrets directly in `.env` files at runtime.
## Install

```shell
composer require itk-dev/vault-bundle
composer require itk-dev/vault-bundle --no-scripts
```

> [!NOTE]
> We use `--no-scripts` since the bundle config may not yet have been created.

### Setup

Create a configuration file at `config/packages/itkdev_vault.yaml` and add the
Expand Down Expand Up @@ -70,7 +73,7 @@ App\Command\TestCommand:

This bundle also comes with two CLI commands to help debug configuration and to
check that you fetch the expected data from the vault. Use the `--help` option
to symfony console to see the options available for the commands.
to Symfony console to see the options available for the commands.

* `itkdev:vault:login`
* `itkdev:vault:secret`
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
],
"require": {
"php": "^8.0",
"symfony/http-client": "^6.4|^7.0",
"symfony/http-client": "^6.4 || ^7.0 || ^8.0",
"nyholm/psr7": "^1.8",
"itk-dev/vault": "^0.1.0",
"symfony/dependency-injection": "^6.4|^7.0",
"symfony/config": "^6.4|^7.0",
"symfony/http-kernel": "^6.4|^7.0"
"symfony/dependency-injection": "^6.4 || ^7.0 || ^8.0",
"symfony/config": "^6.4 || ^7.0 || ^8.0",
"symfony/http-kernel": "^6.4 || ^7.0 || ^8.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.64"
Expand Down
2 changes: 1 addition & 1 deletion src/Command/VaultLoginCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ protected function configure(): void
{
$this
->addOption('engine-path', null, InputOption::VALUE_REQUIRED, 'Authentication engine path', 'approle')
->addOption('refresh', null, InputOption::VALUE_NONE, 'Refresh token from the vault (by-passing the cache)')
->addOption('refresh', null, InputOption::VALUE_NONE, 'Refresh token from the vault (bypassing the cache)')
;
}

Expand Down
22 changes: 16 additions & 6 deletions src/Command/VaultSecretCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
use ItkDev\Vault\Exception\VaultException;
use ItkDev\Vault\Model\Secret;
use ItkDev\VaultBundle\Service\Vault;
use Psr\SimpleCache\InvalidArgumentException;
use Psr\SimpleCache\InvalidArgumentException as PsrSimpleCacheInvalidArgumentException;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Exception\InvalidArgumentException;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
Expand All @@ -31,18 +32,18 @@ public function __construct(
protected function configure(): void
{
$this
->addOption('path', null, InputOption::VALUE_REQUIRED, 'Vault secret engine path)')
->addOption('path', null, InputOption::VALUE_REQUIRED, 'Vault secret engine path')
->addOption('secret', null, InputOption::VALUE_REQUIRED, 'Name of the secret to fetch')
->addOption('keys', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'List of secret keys to fetch')
->addOption('key', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'List of secret keys to fetch')
->addOption('version-id', null, InputOption::VALUE_REQUIRED, 'Version of the secret to fetch')
->addOption('useCache', null, InputOption::VALUE_NONE, 'Cache the token and secrets fetched')
->addOption('expire', null, InputOption::VALUE_REQUIRED, 'For how long the secrets should be cached (in seconds). The token will be cached based on its expiration time.')
->addOption('refresh', null, InputOption::VALUE_NONE, 'Should both token and secrets be refreshed from the vault (by-passing the cache)')
->addOption('refresh', null, InputOption::VALUE_NONE, 'Should both token and secrets be refreshed from the vault (bypassing the cache)')
;
}

/**
* @throws InvalidArgumentException
* @throws PsrSimpleCacheInvalidArgumentException
* @throws NotFoundException
* @throws VaultException
* @throws \DateMalformedIntervalStringException
Expand All @@ -53,8 +54,17 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$io = new SymfonyStyle($input, $output);

$path = $input->getOption('path');
if (null === $path) {
throw new InvalidArgumentException('The path option is required.');
}
$secret = $input->getOption('secret');
$keys = $input->getOption('keys');
if (null === $secret) {
throw new InvalidArgumentException('The secret option is required.');
}
$keys = $input->getOption('key');
if (empty($keys)) {
throw new InvalidArgumentException('At least one key must be specified.');
}
$version = $input->getOption('version-id');

$useCache = $input->getOption('useCache');
Expand Down
Loading