Skip to content

Commit 6c647ef

Browse files
committed
TASK: update readme to include hint because of package loading order
1 parent dba66ce commit 6c647ef

File tree

1 file changed

+57
-52
lines changed

1 file changed

+57
-52
lines changed

README.md

Lines changed: 57 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
# Flowpack.ContentSecurityPolicy
22

33
<!-- TOC -->
4+
45
* [Flowpack.ContentSecurityPolicy](#flowpackcontentsecuritypolicy)
5-
* [Introduction](#introduction)
6-
* [Usage](#usage)
7-
* [Custom directives and values](#custom-directives-and-values)
8-
* [Show CSP configuration](#show-csp-configuration)
9-
* [Disable or report only](#disable-or-report-only)
10-
* [Nonce](#nonce)
11-
* [Backend](#backend)
12-
* [Thank you](#thank-you)
6+
* [Introduction](#introduction)
7+
* [Usage](#usage)
8+
* [Custom directives and values](#custom-directives-and-values)
9+
* [Show CSP configuration](#show-csp-configuration)
10+
* [Disable or report only](#disable-or-report-only)
11+
* [Nonce](#nonce)
12+
* [Backend](#backend)
13+
* [Thank you](#thank-you)
14+
1315
<!-- TOC -->
1416

1517
## Introduction
@@ -31,56 +33,59 @@ It will use the default configuration which looks like this:
3133

3234
```yaml
3335
Flowpack:
34-
ContentSecurityPolicy:
35-
enabled: true
36-
report-only: false
37-
content-security-policy:
38-
default:
39-
base-uri:
40-
- 'self'
41-
connect-src:
42-
- 'self'
43-
default-src:
44-
- 'self'
45-
form-action:
46-
- 'self'
47-
img-src:
48-
- 'self'
49-
media-src:
50-
- 'self'
51-
frame-src:
52-
- 'self'
53-
object-src:
54-
- 'self'
55-
script-src:
56-
- 'self'
57-
style-src:
58-
- 'self'
59-
style-src-attr:
60-
- 'self'
61-
style-src-elem:
62-
- 'self'
63-
font-src:
64-
- 'self'
65-
custom: [ ]
36+
ContentSecurityPolicy:
37+
enabled: true
38+
report-only: false
39+
content-security-policy:
40+
default:
41+
base-uri:
42+
- 'self'
43+
connect-src:
44+
- 'self'
45+
default-src:
46+
- 'self'
47+
form-action:
48+
- 'self'
49+
img-src:
50+
- 'self'
51+
media-src:
52+
- 'self'
53+
frame-src:
54+
- 'self'
55+
object-src:
56+
- 'self'
57+
script-src:
58+
- 'self'
59+
style-src:
60+
- 'self'
61+
style-src-attr:
62+
- 'self'
63+
style-src-elem:
64+
- 'self'
65+
font-src:
66+
- 'self'
67+
custom: [ ]
6668
```
6769
6870
Now only resources from the same origin are allowed for the most common directives.
6971
It is enabled by default and the report-only mode is disabled.
7072
7173
## Custom directives and values
7274
75+
If you want to override the default config don't forget to add this package as a dependency in the composer.json file
76+
of your package. Otherwise, it might not work because of the loading order of the packages.
77+
7378
The default configuration will probably not suit your needs so you can add your own configuration by adding the array
7479
custom like this in your own yaml configuration files:
7580
7681
```yaml
7782
Flowpack:
78-
ContentSecurityPolicy:
79-
content-security-policy:
80-
custom:
81-
frame-src:
82-
- 'https://www.youtube.com'
83-
- 'https://staticxx.facebook.com'
83+
ContentSecurityPolicy:
84+
content-security-policy:
85+
custom:
86+
frame-src:
87+
- 'https://www.youtube.com'
88+
- 'https://staticxx.facebook.com'
8489
```
8590
8691
If you fully want to override the entire default config then just override the default key in yaml.
@@ -103,11 +108,11 @@ To do this simply add `{nonce}` as an option in a directive. Like this:
103108

104109
```yaml
105110
Flowpack:
106-
ContentSecurityPolicy:
107-
content-security-policy:
108-
custom:
109-
script-src:
110-
- '{nonce}'
111+
ContentSecurityPolicy:
112+
content-security-policy:
113+
custom:
114+
script-src:
115+
- '{nonce}'
111116
```
112117

113118
Now the header will include a `nonce-automatedgeneratedrandomstring` in the script-src directive.
@@ -117,7 +122,7 @@ The nonce will be automatically added to all your script/style tags.
117122

118123
## Backend
119124

120-
Due to the current nature of the Neos backend being rendered a bit different then the frontend a separate policy is
125+
Due to the current nature of the Neos backend being rendered a bit different then the frontend a separate policy is
121126
added for the backend.
122127
I currently have found no suitable way the add the nonce in the inline scripts in the Neos UI package.
123128
So the CSP for the backend looks like this:

0 commit comments

Comments
 (0)