Skip to content

Commit 32e0525

Browse files
author
Oleksii Korshenko
authored
Merge pull request #566 from magento-falcons/MAGETWO-59376
Fixed issue: - Split Deployment - scrub sensitive data - override config values by environment
2 parents a77e621 + fbd1d3d commit 32e0525

File tree

55 files changed

+2413
-104
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+2413
-104
lines changed

app/code/Magento/Authorizenet/etc/di.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,14 @@
1616
<argument name="storage" xsi:type="object">Magento\Authorizenet\Model\Directpost\Session\Storage</argument>
1717
</arguments>
1818
</type>
19+
<type name="Magento\Config\Model\Config\Export\ExcludeList">
20+
<arguments>
21+
<argument name="configs" xsi:type="array">
22+
<item name="payment/authorizenet_directpost/login" xsi:type="string">1</item>
23+
<item name="payment/authorizenet_directpost/trans_key" xsi:type="string">1</item>
24+
<item name="payment/authorizenet_directpost/trans_md5" xsi:type="string">1</item>
25+
<item name="payment/authorizenet_directpost/merchant_email" xsi:type="string">1</item>
26+
</argument>
27+
</arguments>
28+
</type>
1929
</config>

app/code/Magento/Backend/etc/di.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,4 +214,22 @@
214214
</argument>
215215
</arguments>
216216
</type>
217+
<type name="Magento\Config\Model\Config\Export\ExcludeList">
218+
<arguments>
219+
<argument name="configs" xsi:type="array">
220+
<item name="trans_email/ident_general/name" xsi:type="string">1</item>
221+
<item name="trans_email/ident_general/email" xsi:type="string">1</item>
222+
<item name="trans_email/ident_sales/name" xsi:type="string">1</item>
223+
<item name="trans_email/ident_sales/email" xsi:type="string">1</item>
224+
<item name="trans_email/ident_support/name" xsi:type="string">1</item>
225+
<item name="trans_email/ident_support/email" xsi:type="string">1</item>
226+
<item name="trans_email/ident_custom1/name" xsi:type="string">1</item>
227+
<item name="trans_email/ident_custom1/email" xsi:type="string">1</item>
228+
<item name="trans_email/ident_custom2/name" xsi:type="string">1</item>
229+
<item name="trans_email/ident_custom2/email" xsi:type="string">1</item>
230+
<item name="admin/url/custom" xsi:type="string">1</item>
231+
<item name="admin/url/custom_path" xsi:type="string">1</item>
232+
</argument>
233+
</arguments>
234+
</type>
217235
</config>

app/code/Magento/Braintree/etc/di.xml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@
365365
</arguments>
366366
</virtualType>
367367
<!-- END PayPal commands -->
368-
368+
369369
<!-- Value handlers infrastructure -->
370370
<type name="Magento\Braintree\Gateway\Response\VaultDetailsHandler">
371371
<arguments>
@@ -452,7 +452,7 @@
452452
</arguments>
453453
</virtualType>
454454
<!-- END PayPal value handlers infrastructure -->
455-
455+
456456
<!-- Void Command -->
457457
<virtualType name="BraintreeVoidCommand" type="Magento\Payment\Gateway\Command\GatewayCommand">
458458
<arguments>
@@ -544,4 +544,16 @@
544544
</arguments>
545545
</type>
546546
<!-- END Settlement Report Section -->
547+
<type name="Magento\Config\Model\Config\Export\ExcludeList">
548+
<arguments>
549+
<argument name="configs" xsi:type="array">
550+
<item name="payment/braintree/merchant_id" xsi:type="string">1</item>
551+
<item name="payment/braintree/public_key" xsi:type="string">1</item>
552+
<item name="payment/braintree/private_key" xsi:type="string">1</item>
553+
<item name="payment/braintree/merchant_account_id" xsi:type="string">1</item>
554+
<item name="payment/braintree/kount_id" xsi:type="string">1</item>
555+
<item name="payment/braintree_paypal/merchant_name_override" xsi:type="string">1</item>
556+
</argument>
557+
</arguments>
558+
</type>
547559
</config>

app/code/Magento/Checkout/etc/di.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,11 @@
4242
</argument>
4343
</arguments>
4444
</type>
45+
<type name="Magento\Config\Model\Config\Export\ExcludeList">
46+
<arguments>
47+
<argument name="configs" xsi:type="array">
48+
<item name="checkout/payment_failed/copy_to" xsi:type="string">1</item>
49+
</argument>
50+
</arguments>
51+
</type>
4552
</config>
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Config\App\Config\Source;
7+
8+
use Magento\Config\Model\Config\Export\ExcludeList;
9+
use Magento\Framework\App\Config\ConfigSourceInterface;
10+
use Magento\Framework\App\Config\ScopeConfigInterface;
11+
12+
class DumpConfigSourceAggregated implements DumpConfigSourceInterface
13+
{
14+
/**
15+
* @var ExcludeList
16+
*/
17+
private $excludeList;
18+
19+
/**
20+
* @var ConfigSourceInterface[]
21+
*/
22+
private $sources;
23+
24+
/**
25+
* @var array
26+
*/
27+
private $excludedFields;
28+
29+
/**
30+
* @var array
31+
*/
32+
private $data;
33+
34+
/**
35+
* @param ExcludeList $excludeList
36+
* @param array $sources
37+
*/
38+
public function __construct(ExcludeList $excludeList, array $sources = [])
39+
{
40+
$this->excludeList = $excludeList;
41+
$this->sources = $sources;
42+
}
43+
44+
/**
45+
* Retrieve aggregated configuration from all available sources.
46+
*
47+
* @param string $path
48+
* @return array
49+
*/
50+
public function get($path = '')
51+
{
52+
$path = (string)$path;
53+
$data = [];
54+
55+
if (isset($this->data[$path])) {
56+
return $this->data[$path];
57+
}
58+
59+
$this->sortSources();
60+
61+
foreach ($this->sources as $sourceConfig) {
62+
/** @var ConfigSourceInterface $source */
63+
$source = $sourceConfig['source'];
64+
$data = array_replace_recursive($data, $source->get($path));
65+
}
66+
67+
$this->excludedFields = [];
68+
$this->filterChain($path, $data);
69+
70+
return $this->data[$path] = $data;
71+
}
72+
73+
/**
74+
* Recursive filtering of sensitive data
75+
*
76+
* @param string $path
77+
* @param array $data
78+
* @return void
79+
*/
80+
private function filterChain($path, &$data)
81+
{
82+
foreach ($data as $subKey => &$subData) {
83+
$newPath = $path ? $path . '/' . $subKey : $subKey;
84+
$filteredPath = $this->filterPath($newPath);
85+
86+
if (
87+
$filteredPath
88+
&& !is_array($data[$subKey])
89+
&& $this->excludeList->isPresent($filteredPath)
90+
) {
91+
$this->excludedFields[$newPath] = $filteredPath;
92+
93+
unset($data[$subKey]);
94+
} elseif (is_array($subData)) {
95+
$this->filterChain($newPath, $subData);
96+
}
97+
}
98+
}
99+
100+
/**
101+
* Eliminating scope info from path
102+
*
103+
* @param string $path
104+
* @return null|string
105+
*/
106+
private function filterPath($path)
107+
{
108+
$parts = explode('/', $path);
109+
110+
// Check if there are enough parts to recognize scope
111+
if (count($parts) < 3) {
112+
return null;
113+
}
114+
115+
if ($parts[0] === ScopeConfigInterface::SCOPE_TYPE_DEFAULT) {
116+
unset($parts[0]);
117+
} else {
118+
unset($parts[0], $parts[1]);
119+
}
120+
121+
return implode('/', $parts);
122+
}
123+
124+
/**
125+
* Sort sources ASC from higher priority to lower
126+
*
127+
* @return void
128+
*/
129+
private function sortSources()
130+
{
131+
uasort($this->sources, function ($firstItem, $secondItem) {
132+
return $firstItem['sortOrder'] > $secondItem['sortOrder'];
133+
});
134+
}
135+
136+
/**
137+
* Retrieves list of field paths were excluded from config dump
138+
* @return array
139+
*/
140+
public function getExcludedFields()
141+
{
142+
$this->get();
143+
144+
$fields = array_values($this->excludedFields);
145+
$fields = array_unique($fields);
146+
147+
return $fields;
148+
}
149+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Config\App\Config\Source;
7+
8+
use Magento\Framework\App\Config\ConfigSourceInterface;
9+
10+
/**
11+
* Interface DumpConfigSourceInterface
12+
*/
13+
interface DumpConfigSourceInterface extends ConfigSourceInterface
14+
{
15+
/**
16+
* Retrieves list of field paths were excluded from config dump
17+
*
18+
* @return array
19+
*/
20+
public function getExcludedFields();
21+
}

app/code/Magento/Config/App/Config/Type/System.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Magento\Framework\App\Config\ConfigTypeInterface;
99
use Magento\Framework\App\Config\ConfigSourceInterface;
1010
use Magento\Framework\App\Config\Spi\PostProcessorInterface;
11+
use Magento\Framework\App\Config\Spi\PreProcessorInterface;
1112
use Magento\Framework\Cache\FrontendInterface;
1213
use Magento\Framework\DataObject;
1314
use Magento\Store\Model\Config\Processor\Fallback;
@@ -38,6 +39,11 @@ class System implements ConfigTypeInterface
3839
*/
3940
private $postProcessor;
4041

42+
/**
43+
* @var PreProcessorInterface
44+
*/
45+
private $preProcessor;
46+
4147
/**
4248
* @var FrontendInterface
4349
*/
@@ -59,17 +65,20 @@ class System implements ConfigTypeInterface
5965
* @param PostProcessorInterface $postProcessor
6066
* @param Fallback $fallback
6167
* @param FrontendInterface $cache
68+
* @param PreProcessorInterface $preProcessor
6269
* @param int $cachingNestedLevel
6370
*/
6471
public function __construct(
6572
ConfigSourceInterface $source,
6673
PostProcessorInterface $postProcessor,
6774
Fallback $fallback,
6875
FrontendInterface $cache,
76+
PreProcessorInterface $preProcessor,
6977
$cachingNestedLevel = 1
7078
) {
7179
$this->source = $source;
7280
$this->postProcessor = $postProcessor;
81+
$this->preProcessor = $preProcessor;
7382
$this->cache = $cache;
7483
$this->cachingNestedLevel = $cachingNestedLevel;
7584
$this->fallback = $fallback;
@@ -86,7 +95,9 @@ public function get($path = '')
8695
if (!$this->data) {
8796
$data = $this->cache->load(self::CONFIG_TYPE);
8897
if (!$data) {
89-
$data = $this->fallback->process($this->source->get());
98+
$data = $this->preProcessor->process($this->source->get());
99+
$this->data = new DataObject($data);
100+
$data = $this->fallback->process($data);
90101
$this->data = new DataObject($data);
91102
$data = $this->postProcessor->process($data);
92103
$this->data = new DataObject($data);

0 commit comments

Comments
 (0)