You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* add CSP types
* add csp stuff to config
* add csp to SSRRenderOptions
* lay some groundwork
* fall back to default-src
* more stuff
* generate meta tags last
* move CSP logic out into separate (and more testable) class
* fixes
* fix
* lint
* add test to show CSP headers are working
* test for <meta http-equiv> tags
* lint
* polyfill web crypto API in node
* add install-crypto module for node-a-like environments
* add relevant subset of sjcl
* start tidying up
* remove some unused code
* move some stuff out of the prototype
* use a class
* more tidying
* more tidying
* more tidying
* fix all type errors
* store init vector and hash key as typed arrays
* convert to closure
* more tidying
* hoist block
* more tidying
* use textdecoder
* create textencoder once
* more tidying
* simplify further
* more tidying
* more tidying
* simplify
* radically simplify
* simplify further
* more crypto stuff
* use node crypto module to generate hashes where possible
* remove unnecessary awaits
* fix mutation bug
* trick esbuild
* windows fix, hopefully
* add unsafe-inline styles in dev
* gah windows
* oops
* change install_fetch back to __fetch_polyfill (ugh)
* revert cosmetic changes
* one base64 implementation is probably enough
* changeset
* document CSP stuff
* remove out of date comment
* add TODO to remove node crypto stuff eventually
* start adding CSP unit tests
* various fixes, suppress strict-dynamic in dev
* always create a nonce if template needs it, regardless of mode
* comment out strict-dynamic handling for now
* lint
Copy file name to clipboardExpand all lines: documentation/docs/14-configuration.md
+30Lines changed: 30 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,13 @@ const config = {
17
17
adapter:null,
18
18
amp:false,
19
19
appDir:'_app',
20
+
csp: {
21
+
mode:'auto',
22
+
directives: {
23
+
'default-src':undefined
24
+
// ...
25
+
}
26
+
},
20
27
files: {
21
28
assets:'static',
22
29
hooks:'src/hooks',
@@ -82,6 +89,29 @@ Enable [AMP](#amp) mode.
82
89
83
90
The directory relative to `paths.assets` where the built JS and CSS (and imported assets) are served from. (The filenames therein contain content-based hashes, meaning they can be cached indefinitely). Must not start or end with `/`.
84
91
92
+
### csp
93
+
94
+
An object containing zero or more of the following values:
95
+
96
+
-`mode` — 'hash', 'nonce' or 'auto'
97
+
-`directives` — an object of `[directive]: value[]` pairs.
98
+
99
+
[Content Security Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy) configuration. CSP helps to protect your users against cross-site scripting (XSS) attacks, by limiting the places resources can be loaded from. For example, a configuration like this...
100
+
101
+
```js
102
+
{
103
+
directives: {
104
+
'script-src': ['self']
105
+
}
106
+
}
107
+
```
108
+
109
+
...would prevent scripts loading from external sites. SvelteKit will augment the specified directives with nonces or hashes (depending on `mode`) for any inline styles and scripts it generates.
110
+
111
+
When pages are prerendered, the CSP header is added via a `<meta http-equiv>` tag (note that in this case, `frame-ancestors`, `report-uri` and `sandbox` directives will be ignored).
112
+
113
+
> When `mode` is `'auto'`, SvelteKit will use nonces for dynamically rendered pages and hashes for prerendered pages. Using nonces with prerendered pages is insecure and therefore forbiddem.
114
+
85
115
### files
86
116
87
117
An object containing zero or more of the following `string` values:
0 commit comments