-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from experius/feature/ARCI-143_introduce-on-off…
…-switch Introduce on off switch and repair system.xml configuration
- Loading branch information
Showing
6 changed files
with
90 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
/** | ||
* Copyright © Experius B.V. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Experius\Csp\Plugin\Magento\Csp\Api\Data; | ||
|
||
use Magento\Framework\App\Config\ScopeConfigInterface; | ||
|
||
class ModeConfiguredInterface | ||
{ | ||
const XML_PATH_CSP_REPORTING_ENABLED = 'experius_csp/general/reporting_enabled'; | ||
|
||
/** | ||
* @var ScopeConfigInterface | ||
*/ | ||
protected $scopeConfig; | ||
|
||
public function __construct( | ||
ScopeConfigInterface $scopeConfig | ||
) { | ||
$this->scopeConfig = $scopeConfig; | ||
} | ||
|
||
/** | ||
* After getReportUri() plugin to be able to disable Content Security Policy reporting using configuration | ||
* | ||
* @param \Magento\Csp\Api\Data\ModeConfiguredInterface $subject | ||
* @param $result | ||
* @return string | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function afterGetReportUri( | ||
\Magento\Csp\Api\Data\ModeConfiguredInterface $subject, | ||
$result | ||
): ?string { | ||
if (!$this->scopeConfig->isSetFlag(self::XML_PATH_CSP_REPORTING_ENABLED)) { | ||
// Return empty reporting url to disable reporting | ||
return null; | ||
} | ||
|
||
return $result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,20 @@ | ||
<?xml version="1.0" ?> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd"> | ||
<acl> | ||
<resources> | ||
<resource id="Magento_Backend::admin"> | ||
<resource id="Experius_Csp::report" sortOrder="10" title="Report"> | ||
<resource id="Experius_Csp::report_delete" sortOrder="20" title="Delete Report"/> | ||
<resource id="Experius_Csp::report_view" sortOrder="40" title="View Report"/> | ||
</resource> | ||
</resource> | ||
</resources> | ||
</acl> | ||
<acl> | ||
<resources> | ||
<resource id="Magento_Backend::admin"> | ||
<resource id="Experius_Csp::report" sortOrder="10" title="Report"> | ||
<resource id="Experius_Csp::report_delete" sortOrder="20" title="Delete Report"/> | ||
<resource id="Experius_Csp::report_view" sortOrder="40" title="View Report"/> | ||
</resource> | ||
</resource> | ||
<resource id="Magento_Backend::stores"> | ||
<resource id="Magento_Backend::stores_settings"> | ||
<resource id="Magento_Config::config"> | ||
<resource id="Experius_Csp::config_experius_csp" title="Experius Csp Reporting"/> | ||
</resource> | ||
</resource> | ||
</resource> | ||
</resources> | ||
</acl> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters