Skip to content

Commit f2cc2da

Browse files
authored
Merge pull request #2 from basecom/feat/add-readme
Feat add readme
2 parents 3edae74 + 496c4ba commit f2cc2da

File tree

3 files changed

+99
-2
lines changed

3 files changed

+99
-2
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,20 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1515

1616
### Fixed
1717

18-
## [1.0.1] - 2020-01-01
18+
## [1.0.2] - 2024-08-05
19+
20+
### Added
21+
22+
- Added README
23+
24+
## [1.0.1] - 2024-08-02
1925

2026
### Fixed
2127

2228
- Fixed issue where the fetch directive was added twice to the CSP header content.
2329

2430
## [1.0.0] - 2024-08-02
2531

32+
[1.0.2]: https://github.com/basecom/magento2-csp-split-header/compare/v1.0.1...v1.0.2
2633
[1.0.1]: https://github.com/basecom/magento2-csp-split-header/compare/v1.0.0...v1.0.1
2734
[1.0.0]: https://github.com/basecom/magento2-csp-split-header/releases/tag/v1.0.0

README.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Basecom_CspSplitHeader Magento 2 Module
2+
3+
<div style="text-align: center;">
4+
5+
[![Software License][ico-license]](LICENSE)
6+
![Supported Magento Versions][ico-compatibility]
7+
8+
</div>
9+
10+
---
11+
12+
> [!IMPORTANT]
13+
> As of Magento 2.4.7 it is no longer possible to deactivate the Magento CSP module.
14+
15+
With a growing _Content Security Policies_ (CSP) whitelist, the problem can arise that the
16+
headers `Content-Security-Policy-Report-Only` and/or `Content-Security-Policy` become so large that they exceed the
17+
maximum permitted size of a header field, causing the web server to not process the response any further.
18+
19+
The CSP mechanism allows multiple policies to be specified for a resource, including via the `Content-Security-Policy`
20+
header, the `Content-Security-Policy-Report-Only` header and a `meta`
21+
element [[MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy#multiple_content_security_policies)].
22+
__Therefore, the headers can be specified more than once.__
23+
24+
This is where the module comes into play. It implements an _after method plugin_ for the
25+
method `Magento\Csp\Model\Policy\Renderer\SimplePolicyHeaderRenderer::render`, which replaces the existing CSP headers
26+
via the method `\Magento\Framework\App\Response\HttpInterface::setHeader`. The header is read, split so that the syntax
27+
remains valid, and replaced by the new headers. The result is a separate header for each directive, each of which should
28+
no longer exceed the maximum permitted length of the web server.
29+
30+
> [!TIP]
31+
> If the headers are too large even after splitting, try to identify unnecessary Magento modules and remove them.
32+
33+
## Installation
34+
35+
1. Install it into your Magento 2 project with composer:
36+
37+
```console
38+
composer require basecom/magento2-csp-split-header
39+
```
40+
41+
2. Enable module
42+
43+
```console
44+
bin/magento setup:upgrade
45+
```
46+
47+
## Configuration
48+
49+
| Config | Default Value | Description |
50+
|-------------------------------------------------------------|----------------|------------------------------------------------------------|
51+
| `basecom_csp_split_header/settings/header_splitting_enable` | 0 _(disabled)_ | enables (1) / disables (0) the splitting of the CSP header |
52+
| `basecom_csp_split_header/settings/max_header_size` | 8000 | maximum allowed header size |
53+
54+
These values can be updated in the system configuration under `Basecom -> Content Security Policy -> Enable`.
55+
56+
## Example
57+
58+
1. CSP splitting _disabled_
59+
60+
```HTTP
61+
Content-Security-Policy: default-src 'self' https://example.com; connect-src 'none'; script-src https://example.com/;
62+
```
63+
64+
2. CSP splitting _enabled_
65+
66+
```HTTP
67+
Content-Security-Policy: default-src 'self' https://example.com;
68+
Content-Security-Policy: connect-src 'none';
69+
Content-Security-Policy: script-src https://example.com/;
70+
```
71+
72+
## Contributing
73+
74+
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
75+
76+
## Security
77+
78+
If you discover any security related issues, please email <[email protected]> instead of using the issue tracker.
79+
80+
## License
81+
82+
The MIT License (MIT). Please see [License File](LICENSE) for more information.
83+
84+
## Copyright
85+
86+
&copy; 2024 basecom GmbH & Co. KG
87+
88+
[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square
89+
90+
[ico-compatibility]: https://img.shields.io/badge/magento-2.4-brightgreen.svg?logo=magento&longCache=true&style=flat-square

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "basecom/magento2-csp-split-header",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"description": "N/A",
55
"type": "magento2-module",
66
"license": [

0 commit comments

Comments
 (0)