Skip to content
This repository was archived by the owner on Jul 12, 2020. It is now read-only.

Commit af5f2b3

Browse files
committed
Merge branch 'develop'
2 parents a6597a6 + df2f335 commit af5f2b3

22 files changed

+485
-28
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ This project adheres to [Semantic Versioning](http://semver.org/).
2828

2929
* (empty)
3030

31+
## 1.1.1 (2018-03-06)
32+
33+
### Added
34+
35+
* Added support for resolving Symfony parameters using environment placeholders (Symfony 3.2+)
36+
* Added rewriting Doctrine configuration key "url" (Symfony 4.0+)
37+
* Added Composer scripts for PHPUnit
38+
* Added Composer scripts for PHP CS Fixer
39+
3140
## 1.1.0 (2018-01-20)
3241

3342
### Added

CONTRIBUTING.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,26 @@ The following steps are required:
4545

4646
* Check the code coverage in order to stay at 100%:
4747

48+
```console
49+
$ composer test-coverage
50+
```
51+
52+
or
53+
4854
```console
4955
$ ./vendor/bin/phpunit -v --coverage-text
5056
```
5157

5258
* Run PHP CS Fixer for coding standards / code style:
5359

5460
```console
55-
$ ./vendor/bin/php-cs-fixer fix -v --dry-run --diff .
61+
$ composer cs
62+
```
63+
64+
or
65+
66+
```console
67+
$ ./vendor/bin/php-cs-fixer fix -v --dry-run --diff
5668
```
5769

5870
Automated versions of these checks will run during the build process.

Console/Processor/DecryptProcessor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function renderDecryptOutput(DecryptRequest $request, OutputInterface $ou
7979

8080
$algorithmConfig = $this->algorithmConfigContainer->get($request->getAlgorithmId());
8181

82-
$plaintextValue = $this->getEncryptedValue($request);
82+
$encryptedValue = $this->getEncryptedValue($request);
8383

8484
$activeKeyConfig = $this->activeKeyConfigProvider->getActiveKeyConfiguration(
8585
$request->isKeyProvided(),
@@ -90,7 +90,7 @@ public function renderDecryptOutput(DecryptRequest $request, OutputInterface $ou
9090
$transformedKey = $this->transformedKeyProvider->getTransformedKey($activeKeyConfig);
9191

9292
$decryptedValue = $algorithmConfig->getDecrypter()
93-
->decryptValue($plaintextValue, $transformedKey->getFinalKey());
93+
->decryptValue($encryptedValue, $transformedKey->getFinalKey());
9494

9595
$this->renderer->renderOutput($decryptedValue, $transformedKey, $output);
9696
}

DependencyInjection/BundleConfiguration/ServiceDefinition/Rewriter/DoctrineRewriter.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,5 +136,7 @@ private function replaceConnectionArguments(array &$serviceConnArguments, array
136136
->replaceArgumentIfExists($serviceConnArguments, $resolvedConnConfig, 'user');
137137
$serviceConnArguments = $this->argumentReplacer
138138
->replaceArgumentIfExists($serviceConnArguments, $resolvedConnConfig, 'password');
139+
$serviceConnArguments = $this->argumentReplacer
140+
->replaceArgumentIfExists($serviceConnArguments, $resolvedConnConfig, 'url');
139141
}
140142
}

DependencyInjection/Compiler/ParameterReplacementPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ public function process(ContainerBuilder $container)
3333

3434
$parameterReplacer = $container->get(ServiceNames::PARAMETER_REPLACER);
3535

36-
$parameterReplacer->processParameterBag($parameterBag);
36+
$parameterReplacer->processParameterBag($parameterBag, $container);
3737
}
3838
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the PcdxParameterEncryptionBundle package.
5+
*
6+
* (c) picodexter <https://picodexter.io/>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Picodexter\ParameterEncryptionBundle\DependencyInjection\Parameter;
13+
14+
use Symfony\Component\DependencyInjection\ContainerBuilder;
15+
16+
/**
17+
* EnvironmentPlaceholderResolver.
18+
*/
19+
class EnvironmentPlaceholderResolver implements EnvironmentPlaceholderResolverInterface
20+
{
21+
/**
22+
* @inheritDoc
23+
*/
24+
public function resolveEnvironmentPlaceholders($parameterValue, ContainerBuilder $container)
25+
{
26+
return $container->resolveEnvPlaceholders($parameterValue, true);
27+
}
28+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the PcdxParameterEncryptionBundle package.
5+
*
6+
* (c) picodexter <https://picodexter.io/>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Picodexter\ParameterEncryptionBundle\DependencyInjection\Parameter;
13+
14+
use Symfony\Component\DependencyInjection\ParameterBag\EnvPlaceholderParameterBag;
15+
16+
/**
17+
* EnvironmentPlaceholderResolverFactory.
18+
*/
19+
class EnvironmentPlaceholderResolverFactory
20+
{
21+
/**
22+
* Create environment placeholder resolver.
23+
*
24+
* @param string $classNameToCheck
25+
*
26+
* @return EnvironmentPlaceholderResolverInterface
27+
*/
28+
public static function createResolver($classNameToCheck = EnvPlaceholderParameterBag::class)
29+
{
30+
if (class_exists($classNameToCheck)) {
31+
return new EnvironmentPlaceholderResolver();
32+
}
33+
34+
return new LegacyEnvironmentPlaceholderResolver();
35+
}
36+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the PcdxParameterEncryptionBundle package.
5+
*
6+
* (c) picodexter <https://picodexter.io/>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Picodexter\ParameterEncryptionBundle\DependencyInjection\Parameter;
13+
14+
use Symfony\Component\DependencyInjection\ContainerBuilder;
15+
16+
/**
17+
* EnvironmentPlaceholderResolverInterface.
18+
*/
19+
interface EnvironmentPlaceholderResolverInterface
20+
{
21+
/**
22+
* Resolve environment placeholders.
23+
*
24+
* @param mixed $parameterValue
25+
* @param ContainerBuilder $container
26+
*
27+
* @return mixed
28+
*/
29+
public function resolveEnvironmentPlaceholders($parameterValue, ContainerBuilder $container);
30+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the PcdxParameterEncryptionBundle package.
5+
*
6+
* (c) picodexter <https://picodexter.io/>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Picodexter\ParameterEncryptionBundle\DependencyInjection\Parameter;
13+
14+
use Symfony\Component\DependencyInjection\ContainerBuilder;
15+
16+
/**
17+
* LegacyEnvironmentPlaceholderResolver.
18+
*
19+
* Compatibility layer for Symfony < 3.2 which did not support environment placeholders.
20+
*/
21+
class LegacyEnvironmentPlaceholderResolver implements EnvironmentPlaceholderResolverInterface
22+
{
23+
/**
24+
* @inheritDoc
25+
*/
26+
public function resolveEnvironmentPlaceholders($parameterValue, ContainerBuilder $container)
27+
{
28+
return $parameterValue;
29+
}
30+
}

DependencyInjection/Service/Initializer/Handler/ReplacementSourceDecrypterRegistrationHandler.php

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Picodexter\ParameterEncryptionBundle\DependencyInjection\Service\Initializer\Handler;
1313

1414
use Picodexter\ParameterEncryptionBundle\Configuration\Key\KeyConfiguration;
15+
use Picodexter\ParameterEncryptionBundle\DependencyInjection\Parameter\EnvironmentPlaceholderResolverInterface;
1516
use Picodexter\ParameterEncryptionBundle\DependencyInjection\Service\BundleConfigurationValidatorInterface;
1617
use Picodexter\ParameterEncryptionBundle\DependencyInjection\Service\DefinitionFactoryInterface;
1718
use Picodexter\ParameterEncryptionBundle\DependencyInjection\Service\ReferenceFactoryInterface;
@@ -35,6 +36,11 @@ class ReplacementSourceDecrypterRegistrationHandler implements ReplacementSource
3536
*/
3637
private $definitionFactory;
3738

39+
/**
40+
* @var EnvironmentPlaceholderResolverInterface
41+
*/
42+
private $environmentPlaceholderResolver;
43+
3844
/**
3945
* @var ReferenceFactoryInterface
4046
*/
@@ -48,19 +54,22 @@ class ReplacementSourceDecrypterRegistrationHandler implements ReplacementSource
4854
/**
4955
* Constructor.
5056
*
51-
* @param BundleConfigurationValidatorInterface $configValidator
52-
* @param DefinitionFactoryInterface $definitionFactory
53-
* @param ReferenceFactoryInterface $referenceFactory
54-
* @param ServiceNameGeneratorInterface $serviceNameGenerator
57+
* @param BundleConfigurationValidatorInterface $bundleConfigValidator
58+
* @param DefinitionFactoryInterface $definitionFactory
59+
* @param EnvironmentPlaceholderResolverInterface $environmentPlaceholderResolver
60+
* @param ReferenceFactoryInterface $referenceFactory
61+
* @param ServiceNameGeneratorInterface $serviceNameGenerator
5562
*/
5663
public function __construct(
57-
BundleConfigurationValidatorInterface $configValidator,
64+
BundleConfigurationValidatorInterface $bundleConfigValidator,
5865
DefinitionFactoryInterface $definitionFactory,
66+
EnvironmentPlaceholderResolverInterface $environmentPlaceholderResolver,
5967
ReferenceFactoryInterface $referenceFactory,
6068
ServiceNameGeneratorInterface $serviceNameGenerator
6169
) {
62-
$this->bundleConfigValidator = $configValidator;
70+
$this->bundleConfigValidator = $bundleConfigValidator;
6371
$this->definitionFactory = $definitionFactory;
72+
$this->environmentPlaceholderResolver = $environmentPlaceholderResolver;
6473
$this->referenceFactory = $referenceFactory;
6574
$this->serviceNameGenerator = $serviceNameGenerator;
6675
}
@@ -75,9 +84,14 @@ public function registerReplacementSourceDecrypters(array $bundleConfig, Contain
7584
$definitions = [];
7685

7786
foreach ($bundleConfig['algorithms'] as $algorithmConfig) {
87+
$decryptionKeyConfig = $this->environmentPlaceholderResolver->resolveEnvironmentPlaceholders(
88+
$algorithmConfig['decryption']['key'],
89+
$container
90+
);
91+
7892
$decryptionKeyConfDef = $this->definitionFactory->createDefinition(
7993
KeyConfiguration::class,
80-
[$algorithmConfig['decryption']['key']]
94+
[$decryptionKeyConfig]
8195
);
8296
$decryptionKeyConfDef->setFactory([
8397
$this->referenceFactory->createReference(ServiceNames::KEY_CONFIGURATION_FACTORY),

0 commit comments

Comments
 (0)