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
Copy file name to clipboardExpand all lines: docs/content/1.getting-started/2.configuration.md
+9-1Lines changed: 9 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,8 +3,9 @@ title: Configuration
3
3
description: ''
4
4
---
5
5
6
-
## Options
6
+
The module by default will register middlewares and route roules to make your application more secure. If you need, you can also modify or disable any of middlewares/routes if you do not need them or your project cannot use them (i.e. some Statically Generated websites will not be able to use middlewares).
7
7
8
+
## Configuration Types
8
9
9
10
Each middleware configuration object is build using same TS type:
10
11
@@ -15,6 +16,9 @@ export type MiddlewareConfiguration<MIDDLEWARE> = {
15
16
}
16
17
```
17
18
19
+
* `value` is the value of certain header or middleware. It may be a simple string or an object depending on the method.
20
+
* `route` is the route that should this header or middleware be attached to. By default for routeRoules (headers) the route is `/**` and for middlewares is `''` (empty string) -> global middleware.
Copy file name to clipboardExpand all lines: docs/content/2.middlewares/1.headers.md
+199-1Lines changed: 199 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,9 @@ title: Headers
3
3
description: ''
4
4
---
5
5
6
-
This middleware will help you solve [this](https://cheatsheetseries.owasp.org/cheatsheets/Nodejs_Security_Cheat_Sheet.html#use-appropriate-security-headers) security problem.
6
+
A set of Nuxt `routeRoules` that will add appriopriate security headers to your response that will make your application more secure by default. All headers can be overriden by using the module configuration or by overriding certain routes.
7
+
8
+
It will help you solve [this](https://cheatsheetseries.owasp.org/cheatsheets/Nodejs_Security_Cheat_Sheet.html#use-appropriate-security-headers) security problem.
7
9
8
10
```ts
9
11
exporttypeMiddlewareConfiguration<MIDDLEWARE> = {
@@ -47,3 +49,199 @@ To write a custom logic for this middleware follow this pattern:
47
49
}
48
50
}
49
51
```
52
+
53
+
## `Content-Security-Policy`
54
+
55
+
Content Security Policy (CSP) helps prevent unwanted content from being injected/loaded into your webpages. This can mitigate cross-site scripting (XSS) vulnerabilities, clickjacking, formjacking, malicious frames, unwanted trackers, and other web client-side attacks.
56
+
57
+
Read more about this header [here](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP).
The HTTP Cross-Origin-Embedder-Policy (COEP) response header prevents a document from loading any cross-origin resources that don't explicitly grant the document permission.
72
+
73
+
Read more about this header [here](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Embedder-Policy).
74
+
75
+
Default value:
76
+
77
+
```ts
78
+
crossOriginEmbedderPolicy: {
79
+
value: "require-corp",
80
+
route: '/**',
81
+
},
82
+
```
83
+
84
+
## `Cross-Origin-Opener-Policy`
85
+
86
+
The HTTP Cross-Origin-Opener-Policy (COOP) response header allows you to ensure a top-level document does not share a browsing context group with cross-origin documents. COOP will process-isolate your document and potential attackers can't access your global object if they were to open it in a popup, preventing a set of cross-origin attacks dubbed XS-Leaks.
87
+
88
+
Read more about this header [here](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Opener-Policy).
89
+
90
+
Default value:
91
+
92
+
```ts
93
+
crossOriginOpenerPolicy: {
94
+
value: "same-origin",
95
+
route: '/**',
96
+
},
97
+
```
98
+
99
+
## `Cross-Origin-Resource-Policy`
100
+
101
+
Cross-Origin Resource Policy is a policy set by the Cross-Origin-Resource-Policy HTTP header that lets web sites and applications opt in to protection against certain requests from other origins (such as those issued with elements like `<script>` and `<img>`), to mitigate speculative side-channel attacks, like Spectre, as well as Cross-Site Script Inclusion attacks. CORP is an additional layer of protection beyond the default same-origin policy. Cross-Origin Resource Policy complements Cross-Origin Read Blocking (CORB), which is a mechanism to prevent some cross-origin reads by default.
102
+
103
+
Read more about this header [here](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cross-Origin_Resource_Policy_(CORP)).
104
+
105
+
Default value:
106
+
107
+
```ts
108
+
crossOriginResourcePolicy: {
109
+
value: "same-origin",
110
+
route: '/**',
111
+
},
112
+
```
113
+
114
+
## `Origin-Agent-Cluster`
115
+
116
+
Origin-Agent-Cluster is a new HTTP response header that instructs the browser to prevent synchronous scripting access between same-site cross-origin pages. Browsers may also use Origin-Agent-Cluster as a hint that your origin should get its own, separate resources, such as a dedicated process.
117
+
118
+
Read more about this header [here](https://web.dev/origin-agent-cluster).
119
+
120
+
Default value:
121
+
122
+
```ts
123
+
originAgentCluster: {
124
+
value: "?1",
125
+
route: '/**',
126
+
},
127
+
```
128
+
129
+
## `Referrer-Policy`
130
+
131
+
The Referrer-Policy HTTP header controls how much referrer information (sent with the Referer header) should be included with requests. Aside from the HTTP header, you can set this policy in HTML.
132
+
133
+
Read more about this header [here](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referrer-Policy).
134
+
135
+
Default value:
136
+
137
+
```ts
138
+
referrerPolicy: {
139
+
value: "no-referrer",
140
+
route: '/**',
141
+
},
142
+
```
143
+
144
+
## `Strict-Transport-Security`
145
+
146
+
The HTTP Strict-Transport-Security response header (often abbreviated as HSTS) informs browsers that the site should only be accessed using HTTPS, and that any future attempts to access it using HTTP should automatically be converted to HTTPS.
147
+
148
+
Read more about this header [here](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security).
149
+
150
+
Default value:
151
+
152
+
```ts
153
+
strictTransportSecurity: {
154
+
value: "max-age=15552000; includeSubDomains",
155
+
route: '/**',
156
+
},
157
+
```
158
+
159
+
## `X-Content-Type-Options`
160
+
161
+
The X-Content-Type-Options response HTTP header is a marker used by the server to indicate that the MIME types advertised in the Content-Type headers should be followed and not be changed. The header allows you to avoid MIME type sniffing by saying that the MIME types are deliberately configured.
162
+
163
+
Read more about this header [here](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Content-Type-Options).
164
+
165
+
Default value:
166
+
167
+
```ts
168
+
xContentTypeOptions: {
169
+
value: "nosniff",
170
+
route: '/**',
171
+
},
172
+
```
173
+
174
+
## `X-DNS-Prefetch-Control`
175
+
176
+
The X-DNS-Prefetch-Control HTTP response header controls DNS prefetching, a feature by which browsers proactively perform domain name resolution on both links that the user may choose to follow as well as URLs for items referenced by the document, including images, CSS, JavaScript, and so forth. This prefetching is performed in the background, so that the DNS is likely to have been resolved by the time the referenced items are needed. This reduces latency when the user clicks a link.
177
+
178
+
Read more about this header [here](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-DNS-Prefetch-Control).
179
+
180
+
Default value:
181
+
182
+
```ts
183
+
xDNSPrefetchControl: {
184
+
value: "off",
185
+
route: '/**',
186
+
},
187
+
```
188
+
189
+
## `X-Download-Options`
190
+
191
+
The X-Download-Options HTTP header has only one option: X-Download-Options: noopen. This is for Internet Explorer from version 8 on to instruct the browser not to open a download directly in the browser but instead to provide only the �Save� option. The user has to first save it and then open it in an application.
192
+
193
+
Read more about this header [here](https://webtechsurvey.com/response-header/x-download-options).
194
+
195
+
Default value:
196
+
197
+
```ts
198
+
xDownloadOptions: {
199
+
value: "noopen",
200
+
route: '/**',
201
+
},
202
+
```
203
+
204
+
## `X-Frame-Options`
205
+
206
+
The X-Frame-Options HTTP response header can be used to indicate whether or not a browser should be allowed to render a page in a `<frame>`, `<iframe>`, `<embed>` or `<object>`. Sites can use this to avoid click-jacking attacks, by ensuring that their content is not embedded into other sites.
207
+
208
+
Read more about this header [here](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options).
209
+
210
+
Default value:
211
+
212
+
```ts
213
+
xFrameOptions: {
214
+
value: "SAMEORIGIN",
215
+
route: '/**',
216
+
},
217
+
```
218
+
219
+
## `X-Permitted-Cross-Domain-Policies`
220
+
221
+
The X-Permitted-Cross-Domain-Policies header is used to permit cross-domain requests from Flash and PDF documents. In most cases, these permissions are defined in an XML document called crossdomain.xml found in the root directory of the web page. For situations in which the root directory cannot be specified, however, this header can be used to define a desired meta policy. The X-Permitted-Cross-Domain-Policies header should ideally be set as restrictively as possible.
222
+
223
+
Read more about this header [here](https://www.scip.ch/en/?labs.20180308#:~:text=The%20X%2DPermitted%2DCross%2D,documents%20for%20cross%2Ddomain%20requests.&text=The%20Public%2DKey%2DPins%20header,complexity%20and%20dwindling%20browser%20support.).
224
+
225
+
Default value:
226
+
227
+
```ts
228
+
xPermittedCrossDomainPolicies: {
229
+
value: "none",
230
+
route: '/**',
231
+
},
232
+
```
233
+
234
+
## `X-XSS-Protection`
235
+
236
+
The HTTP X-XSS-Protection response header is a feature of Internet Explorer, Chrome and Safari that stops pages from loading when they detect reflected cross-site scripting (XSS) attacks. These protections are largely unnecessary in modern browsers when sites implement a strong Content-Security-Policy that disables the use of inline JavaScript ('unsafe-inline').
237
+
238
+
Read more about this header [here](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection).
Copy file name to clipboardExpand all lines: docs/content/2.middlewares/2.request-size-limiter.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,9 @@ title: Request Size Limiter
3
3
description: ''
4
4
---
5
5
6
-
This middleware will help you solve [this](https://cheatsheetseries.owasp.org/cheatsheets/Nodejs_Security_Cheat_Sheet.html#set-request-size-limits) security problem.
6
+
This middleware works for `GET`, `POST`, and `DELETE` methods and will throw an `413 Payload Too Large` error when the payload will be larger than the one set in the configuration. Works for both request size and upload file request size.
7
+
8
+
It will help you solve [this](https://cheatsheetseries.owasp.org/cheatsheets/Nodejs_Security_Cheat_Sheet.html#set-request-size-limits) security problem.
Copy file name to clipboardExpand all lines: docs/content/2.middlewares/3.rate-limiter.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,9 @@ title: Rate Limiter
3
3
description: ''
4
4
---
5
5
6
-
This middleware will help you solve [this](https://cheatsheetseries.owasp.org/cheatsheets/Nodejs_Security_Cheat_Sheet.html#take-precautions-against-brute-forcing) security problem.
6
+
This middleware stores ip address of a request in memory and will throw an `429 Too Many Requests` error when there will be too many requests than the number set in the configuration. Based on <https://github.com/jhurliman/node-rate-limiter> and <https://github.com/ptarjan/node-cache>
7
+
8
+
It will help you solve [this](https://cheatsheetseries.owasp.org/cheatsheets/Nodejs_Security_Cheat_Sheet.html#take-precautions-against-brute-forcing) security problem.
Copy file name to clipboardExpand all lines: docs/content/2.middlewares/4.xss-validator.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,9 @@ title: XSS Validator
3
3
description: ''
4
4
---
5
5
6
-
This middleware will help you solve [this](https://cheatsheetseries.owasp.org/cheatsheets/Nodejs_Security_Cheat_Sheet.html#perform-output-escaping) security problem. This middleware is based on https://github.com/leizongmin/js-xss
6
+
This middleware works for both `GET`, `POST` methods and will throw an `400 Bad Request` error when the either body or query params will contain unsecure code. Based on <https://github.com/leizongmin/js-xss>
7
+
8
+
It will help you solve [this](https://cheatsheetseries.owasp.org/cheatsheets/Nodejs_Security_Cheat_Sheet.html#perform-output-escaping) security problem.
Copy file name to clipboardExpand all lines: docs/content/2.middlewares/5.cors-handler.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,9 @@ title: CORS Handler
3
3
description: ''
4
4
---
5
5
6
-
This middleware will help you solve [this](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) security problem. This middleware is based on https://github.com/NozomuIkuta/h3-cors
6
+
This middleware will help you set your CORS options. Based on <https://github.com/NozomuIkuta/h3-cors>
7
+
8
+
This middleware will help you solve [this](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) security problem.
0 commit comments