Skip to content

Commit

Permalink
bug #34922 [FrameworkBundle][Secrets] Hook configured local dotenv fi…
Browse files Browse the repository at this point in the history
…le (fancyweb)

This PR was squashed before being merged into the 4.4 branch.

Discussion
----------

[FrameworkBundle][Secrets] Hook configured local dotenv file

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | #34905
| License       | MIT
| Doc PR        | -

Configured local_dotenv_file does not currently substitute the secrets.vault service definition first argument value, rendering this configuration option useless + we don't need to set defaults in secrets.xml since everything is overriden in FrameworkExtension with the same default values (from the configuration).

Commits
-------

56f542c [FrameworkBundle][Secrets] Hook configured local dotenv file
  • Loading branch information
nicolas-grekas committed Dec 13, 2019
2 parents 212dc53 + 56f542c commit 1d59e1e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
Expand Up @@ -129,7 +129,7 @@ private function addSecretsSection(ArrayNodeDefinition $rootNode)
->canBeDisabled()
->children()
->scalarNode('vault_directory')->defaultValue('%kernel.project_dir%/config/secrets/%kernel.environment%')->cannotBeEmpty()->end()
->scalarNode('local_dotenv_file')->defaultValue('%kernel.project_dir%/.env.local')->end()
->scalarNode('local_dotenv_file')->defaultValue('%kernel.project_dir%/.env.%kernel.environment%.local')->end()
->scalarNode('decryption_env_var')->defaultValue('base64:default::SYMFONY_DECRYPTION_SECRET')->end()
->end()
->end()
Expand Down
Expand Up @@ -1478,7 +1478,9 @@ private function registerSecretsConfiguration(array $config, ContainerBuilder $c

$container->getDefinition('secrets.vault')->replaceArgument(0, $config['vault_directory']);

if (!$config['local_dotenv_file']) {
if ($config['local_dotenv_file']) {
$container->getDefinition('secrets.local_vault')->replaceArgument(0, $config['local_dotenv_file']);
} else {
$container->removeDefinition('secrets.local_vault');
}

Expand Down
Expand Up @@ -7,12 +7,12 @@
<services>
<service id="secrets.vault" class="Symfony\Bundle\FrameworkBundle\Secrets\SodiumVault">
<tag name="container.env_var_loader" />
<argument>%kernel.project_dir%/config/secrets/%kernel.environment%</argument>
<argument>%env(base64:default::SYMFONY_DECRYPTION_SECRET)%</argument>
<argument />
<argument />
</service>

<service id="secrets.local_vault" class="Symfony\Bundle\FrameworkBundle\Secrets\DotenvVault">
<argument>%kernel.project_dir%/.env.local</argument>
<argument />
</service>
</services>
</container>
Expand Up @@ -519,7 +519,7 @@ class_exists(SemaphoreStore::class) && SemaphoreStore::isSupported() ? 'semaphor
'secrets' => [
'enabled' => true,
'vault_directory' => '%kernel.project_dir%/config/secrets/%kernel.environment%',
'local_dotenv_file' => '%kernel.project_dir%/.env.local',
'local_dotenv_file' => '%kernel.project_dir%/.env.%kernel.environment%.local',
'decryption_env_var' => 'base64:default::SYMFONY_DECRYPTION_SECRET',
],
];
Expand Down

0 comments on commit 1d59e1e

Please sign in to comment.