diff options
author | 2021-08-13 00:45:01 +0530 | |
---|---|---|
committer | 2021-08-13 00:45:01 +0530 | |
commit | 2d27d5e66649d4f5baf127a53ee5ae524eae3a59 (patch) | |
tree | c592ea219ac8cd987fc367f57b54034c450ab2ab /src/internal-server/config/shield.js | |
parent | Ferdi v5.6.0 (diff) | |
parent | 5.6.1-nightly.24 [skip ci] (diff) | |
download | ferdium-app-2d27d5e66649d4f5baf127a53ee5ae524eae3a59.tar.gz ferdium-app-2d27d5e66649d4f5baf127a53ee5ae524eae3a59.tar.zst ferdium-app-2d27d5e66649d4f5baf127a53ee5ae524eae3a59.zip |
chore: merge from nightly branch into release branch in prep for next beta
Diffstat (limited to 'src/internal-server/config/shield.js')
-rw-r--r-- | src/internal-server/config/shield.js | 143 |
1 files changed, 143 insertions, 0 deletions
diff --git a/src/internal-server/config/shield.js b/src/internal-server/config/shield.js new file mode 100644 index 000000000..76f430e91 --- /dev/null +++ b/src/internal-server/config/shield.js | |||
@@ -0,0 +1,143 @@ | |||
1 | module.exports = { | ||
2 | /* | ||
3 | |-------------------------------------------------------------------------- | ||
4 | | Content Security Policy | ||
5 | |-------------------------------------------------------------------------- | ||
6 | | | ||
7 | | Content security policy filters out the origins not allowed to execute | ||
8 | | and load resources like scripts, styles and fonts. There are wide | ||
9 | | variety of options to choose from. | ||
10 | */ | ||
11 | csp: { | ||
12 | /* | ||
13 | |-------------------------------------------------------------------------- | ||
14 | | Directives | ||
15 | |-------------------------------------------------------------------------- | ||
16 | | | ||
17 | | All directives are defined in camelCase and here is the list of | ||
18 | | available directives and their possible values. | ||
19 | | | ||
20 | | https://content-security-policy.com | ||
21 | | | ||
22 | | @example | ||
23 | | directives: { | ||
24 | | defaultSrc: ['self', '@nonce', 'cdnjs.cloudflare.com'] | ||
25 | | } | ||
26 | | | ||
27 | */ | ||
28 | directives: { | ||
29 | }, | ||
30 | /* | ||
31 | |-------------------------------------------------------------------------- | ||
32 | | Report only | ||
33 | |-------------------------------------------------------------------------- | ||
34 | | | ||
35 | | Setting `reportOnly=true` will not block the scripts from running and | ||
36 | | instead report them to a URL. | ||
37 | | | ||
38 | */ | ||
39 | reportOnly: false, | ||
40 | /* | ||
41 | |-------------------------------------------------------------------------- | ||
42 | | Set all headers | ||
43 | |-------------------------------------------------------------------------- | ||
44 | | | ||
45 | | Headers staring with `X` have been depreciated, since all major browsers | ||
46 | | supports the standard CSP header. So its better to disable deperciated | ||
47 | | headers, unless you want them to be set. | ||
48 | | | ||
49 | */ | ||
50 | setAllHeaders: false, | ||
51 | |||
52 | /* | ||
53 | |-------------------------------------------------------------------------- | ||
54 | | Disable on android | ||
55 | |-------------------------------------------------------------------------- | ||
56 | | | ||
57 | | Certain versions of android are buggy with CSP policy. So you can set | ||
58 | | this value to true, to disable it for Android versions with buggy | ||
59 | | behavior. | ||
60 | | | ||
61 | | Here is an issue reported on a different package, but helpful to read | ||
62 | | if you want to know the behavior. https://github.com/helmetjs/helmet/pull/82 | ||
63 | | | ||
64 | */ | ||
65 | disableAndroid: true, | ||
66 | }, | ||
67 | |||
68 | /* | ||
69 | |-------------------------------------------------------------------------- | ||
70 | | X-XSS-Protection | ||
71 | |-------------------------------------------------------------------------- | ||
72 | | | ||
73 | | X-XSS Protection saves from applications from XSS attacks. It is adopted | ||
74 | | by IE and later followed by some other browsers. | ||
75 | | | ||
76 | | Learn more at https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection | ||
77 | | | ||
78 | */ | ||
79 | xss: { | ||
80 | enabled: true, | ||
81 | enableOnOldIE: false, | ||
82 | }, | ||
83 | |||
84 | /* | ||
85 | |-------------------------------------------------------------------------- | ||
86 | | Iframe Options | ||
87 | |-------------------------------------------------------------------------- | ||
88 | | | ||
89 | | xframe defines whether or not your website can be embedded inside an | ||
90 | | iframe. Choose from one of the following options. | ||
91 | | @available options | ||
92 | | DENY, SAMEORIGIN, ALLOW-FROM http://example.com | ||
93 | | | ||
94 | | Learn more at https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options | ||
95 | */ | ||
96 | xframe: 'DENY', | ||
97 | |||
98 | /* | ||
99 | |-------------------------------------------------------------------------- | ||
100 | | No Sniff | ||
101 | |-------------------------------------------------------------------------- | ||
102 | | | ||
103 | | Browsers have a habit of sniffing content-type of a response. Which means | ||
104 | | files with .txt extension containing Javascript code will be executed as | ||
105 | | Javascript. You can disable this behavior by setting nosniff to false. | ||
106 | | | ||
107 | | Learn more at https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options | ||
108 | | | ||
109 | */ | ||
110 | nosniff: true, | ||
111 | |||
112 | /* | ||
113 | |-------------------------------------------------------------------------- | ||
114 | | No Open | ||
115 | |-------------------------------------------------------------------------- | ||
116 | | | ||
117 | | IE users can execute webpages in the context of your website, which is | ||
118 | | a serious security risk. Below option will manage this for you. | ||
119 | | | ||
120 | */ | ||
121 | noopen: true, | ||
122 | |||
123 | /* | ||
124 | |-------------------------------------------------------------------------- | ||
125 | | CSRF Protection | ||
126 | |-------------------------------------------------------------------------- | ||
127 | | | ||
128 | | CSRF Protection adds another layer of security by making sure, actionable | ||
129 | | routes does have a valid token to execute an action. | ||
130 | | | ||
131 | */ | ||
132 | csrf: { | ||
133 | enable: true, | ||
134 | methods: ['POST', 'PUT', 'DELETE'], | ||
135 | filterUris: [], | ||
136 | cookieOptions: { | ||
137 | httpOnly: false, | ||
138 | sameSite: true, | ||
139 | path: '/', | ||
140 | maxAge: 7200, | ||
141 | }, | ||
142 | }, | ||
143 | }; | ||