Skip to content

Commit 6ad547b

Browse files
RobbieTheWagnerjacobq
authored andcommitted
Move inline scripts to public folder, document CSP setup (adopted-ember-addons#695)
!! CHERRY PICK !! See f10596e * Add static nonce to scripts This should help us fix CSP issues until CSP supports generating nonces. * Update index.js * Move scripts to public * Add CSP docs
1 parent ba7aa6a commit 6ad547b

File tree

8 files changed

+3298
-5552
lines changed

8 files changed

+3298
-5552
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
"ember-cli-sass": "^10.0.1",
8989
"ember-cli-sri": "^2.1.1",
9090
"ember-cli-uglify": "^3.0.0",
91+
"ember-data": "^3.24.0",
9192
"ember-disable-prototype-extensions": "^1.1.3",
9293
"ember-export-application-global": "^2.0.1",
9394
"ember-load-initializers": "^2.1.2",
File renamed without changes.
File renamed without changes.
File renamed without changes.

tests/dummy/app/router.js

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Router.map(function() {
1616
this.route('guides', function() {
1717
this.route('ci');
1818
this.route('common-issues');
19+
this.route('csp');
1920
this.route('development-and-debugging');
2021
this.route('installation');
2122
this.route('security');

tests/dummy/app/templates/docs.hbs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
{{nav.item "Upgrading" "docs.guides.upgrading"}}
1010
{{nav.item "Development and Debugging" "docs.guides.development-and-debugging"}}
1111
{{nav.item "CI" "docs.guides.ci"}}
12+
{{nav.item "Content Security Policy (CSP)" "docs.guides.csp"}}
1213

1314
{{nav.section "FAQ"}}
1415
{{nav.item "Common Issues" "docs.faq.common-issues"}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Using a Content Security Policy
2+
3+
You may have noticed Electron warns if you do not have a Content Security Policy setup.
4+
This has been the case for quite awhile. To fix it, you may want to setup a CSP that
5+
makes sense for your app.
6+
7+
First, you will need to install [ember-cli-content-security-policy](https://github.com/rwjblue/ember-cli-content-security-policy).
8+
9+
```bash
10+
ember install ember-cli-content-security-policy
11+
```
12+
13+
Then you should start by adding this default config to your `config/environment.js` file
14+
and tweak it further for the needs of your app.
15+
16+
```js
17+
contentSecurityPolicy: {
18+
'default-src': ["'none'"],
19+
'script-src': [
20+
'http://localhost:7020',
21+
'http://localhost:7357',
22+
'http://testemserver',
23+
"'self'",
24+
"'unsafe-inline'"
25+
],
26+
'font-src': ["'self'"],
27+
'frame-src': ['http://localhost:7357', 'http://testemserver/', "'self'"],
28+
'connect-src': ["'self'"],
29+
'img-src': ['data:', "'self'"],
30+
'style-src': ["'self'", "'unsafe-inline'"],
31+
'media-src': ["'self'"]
32+
},
33+
contentSecurityPolicyMeta: true,
34+
```
35+
36+
If you are using ember-auto-import or embroider you will also need to forbid eval there:
37+
38+
```js
39+
autoImport: {
40+
forbidEval: true
41+
},
42+
```

yarn.lock

+3,253-5,552
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)