Skip to content

Commit 9fa7896

Browse files
author
Dale Sikkema
committed
MAGETWO-16192: Security: Clickjacking solution - introduce X-Frame-Options
- change default and backend permission to SAMEORIGIN
1 parent 0d1c8a9 commit 9fa7896

File tree

6 files changed

+8
-9
lines changed

6 files changed

+8
-9
lines changed

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,4 @@
296296
</argument>
297297
</arguments>
298298
</type>
299-
<type name="Magento\Framework\App\Response\Http">
300-
<plugin name="xFrameOptionsHeader" type="Magento\Framework\App\Response\XFrameOptPlugin"/>
301-
</type>
302-
303299
</config>

app/etc/di.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@
136136
<preference for="Magento\Framework\Api\ImageContentValidatorInterface" type="Magento\Framework\Api\ImageContentValidator" />
137137
<preference for="Magento\Framework\Api\ImageProcessorInterface" type="Magento\Framework\Api\ImageProcessor" />
138138
<preference for="Magento\Framework\Code\Reader\ClassReaderInterface" type="Magento\Framework\Code\Reader\ClassReader" />
139+
<type name="Magento\Framework\App\Response\Http">
140+
<plugin name="xFrameOptionsHeader" type="Magento\Framework\App\Response\XFrameOptPlugin"/>
141+
</type>
139142
<type name="Magento\Framework\App\Response\XFrameOptPlugin">
140143
<arguments>
141144
<argument name="xFrameOpt" xsi:type="init_parameter">Magento\Framework\App\Response\XFrameOptPlugin::DEPLOYMENT_CONFIG_X_FRAME_OPT</argument>

lib/internal/Magento/Framework/App/Response/XFrameOptPlugin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ class XFrameOptPlugin
1414
/** Deployment config key for frontend x-frame-options header value */
1515
const DEPLOYMENT_CONFIG_X_FRAME_OPT = 'x-frame-options';
1616

17-
/** Always send DENY in backend x-frame-options header */
18-
const BACKEND_X_FRAME_OPT = 'DENY';
17+
/** Always send SAMEORIGIN in backend x-frame-options header */
18+
const BACKEND_X_FRAME_OPT = 'SAMEORIGIN';
1919

2020
/**
2121
*The header value

lib/internal/Magento/Framework/App/Test/Unit/Response/HttpTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ public function testWakeUpWith()
274274

275275
public function testSetXFrameOptions()
276276
{
277-
$value = 'SAMEORIGIN';
277+
$value = 'DENY';
278278
$this->model->setXFrameOptions($value);
279279
$this->assertSame($value, $this->model->getHeader(Http::HEADER_X_FRAME_OPT)->getFieldValue());
280280
}

setup/src/Magento/Setup/Model/ConfigGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ public function createXFrameConfig()
220220
{
221221
$configData = new ConfigData(ConfigFilePool::APP_ENV);
222222
if ($this->deploymentConfig->get(ConfigOptionsListConstants::CONFIG_PATH_X_FRAME_OPT) === null) {
223-
$configData->set(ConfigOptionsListConstants::CONFIG_PATH_X_FRAME_OPT, 'DENY');
223+
$configData->set(ConfigOptionsListConstants::CONFIG_PATH_X_FRAME_OPT, 'SAMEORIGIN');
224224
}
225225
return $configData;
226226
}

setup/src/Magento/Setup/Test/Unit/Model/ConfigGeneratorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ public function testCreateXFrameConfig()
3636
->with(ConfigOptionsListConstants::CONFIG_PATH_X_FRAME_OPT)
3737
->willReturn(null);
3838
$configData = $this->model->createXFrameConfig();
39-
$this->assertSame('DENY', $configData->getData()[ConfigOptionsListConstants::CONFIG_PATH_X_FRAME_OPT]);
39+
$this->assertSame('SAMEORIGIN', $configData->getData()[ConfigOptionsListConstants::CONFIG_PATH_X_FRAME_OPT]);
4040
}
4141
}

0 commit comments

Comments
 (0)