Skip to content

Commit e1ac64f

Browse files
committed
docs: rewrite
1 parent 4df3fc2 commit e1ac64f

25 files changed

+1780
-1369
lines changed

docs/app.config.ts

+19-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
export default defineAppConfig({
2+
github: {
3+
owner: 'Baroshem',
4+
repo: 'nuxt-security',
5+
branch: 'main'
6+
},
27
docus: {
38
title: 'Nuxt Security',
49
description: '🛡️ Security Module for Nuxt based on HTTP Headers and Middleware',
510
image: '/preview.jpg',
11+
url: 'https://nuxt-security.vercel.app',
612
socials: {
713
twitter: 'jacobandrewsky',
814
github: 'baroshem/nuxt-security',
@@ -15,15 +21,19 @@ export default defineAppConfig({
1521
aside: {
1622
level: 1
1723
},
18-
// github: {
19-
// dir: 'docs/content',
20-
// root: 'docs/content',
21-
// edit: true,
22-
// releases: true,
23-
// owner: 'baroshem',
24-
// repo: 'nuxt-security',
25-
// branch: 'main'
26-
// },
24+
github: {
25+
dir: 'docs/content',
26+
root: 'docs/content',
27+
edit: true,
28+
releases: true,
29+
owner: 'baroshem',
30+
repo: 'nuxt-security',
31+
branch: 'main'
32+
},
33+
cover: {
34+
src: '/preview.png',
35+
alt: 'Security Module for Nuxt based on HTTP Headers and Middleware'
36+
},
2737
header: {
2838
logo: true
2939
}

docs/content/0.index.md

+30-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Automatically configure your app to follow OWASP security patterns and principle
2929

3030
::card-grid
3131
#title
32-
What's included
32+
<div class="center heading">Protect your app with <br/> <span class=highlight>no configuration</span></div>
3333

3434
#root
3535
:ellipsis{left=0px width=40rem top=10rem blur=140px}
@@ -78,6 +78,24 @@ What's included
7878
::
7979
::
8080

81+
::block-hero
82+
---
83+
cta:
84+
- 🚀 Get Started
85+
- /documentation/getting-started/setup
86+
---
87+
#title
88+
<div class="heading">Discover how it helps ship<br/> <span class=highlight>secure applications</span></div>
89+
90+
91+
#description
92+
Nuxt Security solves several security issues automatically by implementing Headers and Middleware accordingly to OWASP & OWASP Top 10 documents. For others, it provides optional middleware that will help you handle more advanced cases like Cross Site Request Forgery.
93+
94+
#support
95+
:video-player{src="https://www.youtube.com/watch?v=8RDPrptc9uU"}
96+
::
97+
98+
8199
<style>
82100
.cta {
83101
color: rgb(15, 23, 42) !important;
@@ -93,4 +111,15 @@ What's included
93111
.highlight {
94112
color: #00dc82
95113
}
114+
115+
.center {
116+
text-align: center;
117+
}
118+
119+
.heading {
120+
margin-bottom: 40px;
121+
font-size: 48px;
122+
font-weight: 700;
123+
line-height: 48px;
124+
}
96125
</style>

docs/content/1.documentation/1.getting-started/1.setup.md

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Having more secure Nuxt project is only one command away ✨
44

55
---
66

7+
:ellipsis{right=0px width=75% blur=150px}
8+
79
Install `nuxt-security` module:
810

911
::code-group

docs/content/1.documentation/1.getting-started/2.configuration.md

+3-57
Original file line numberDiff line numberDiff line change
@@ -4,63 +4,9 @@ Nuxt Security is configured with sensible defaults.
44

55
---
66

7-
The module by default will register **global** middleware and route roules to make your application more secure. You can also modify or disable any of middlewares/routes or your project cannot use them (i.e. some Statically Generated websites will not be able to use middlewares).
8-
9-
## Global middleware
10-
11-
You can add **global** configuration to the module like following:
12-
13-
```js{}[nuxt.config.ts]
14-
export default defineNuxtConfig({
15-
security: {
16-
// Options
17-
}
18-
})
19-
```
20-
21-
You can disable them from the module configuration like following:
22-
23-
```js{}[nuxt.config.ts]
24-
export default defineNuxtConfig({
25-
security: {
26-
rateLimiter: false
27-
}
28-
})
29-
```
30-
31-
In general, the `security` object in nuxt configuration should be used to register functionality that will be used **globally** in your application. For per route configuration, check out the next section.
32-
33-
## Per route middleware
7+
:ellipsis{right=0px width=75% blur=150px}
348

35-
By default, middlewares are configured to work globally, but you can easily configure them per route by using `routeRules`:
36-
37-
```js{}[nuxt.config.ts]
38-
export default defineNuxtConfig({
39-
routeRules: {
40-
'/custom-route': {
41-
security: {
42-
// Options
43-
}
44-
}
45-
}
46-
})
47-
```
48-
49-
By adding this you will have global middleware for all routes (regarding rate limiting) and specific configuration to the `/custom-route` route.
50-
51-
You can also disable certain middlewares per route like following:
52-
53-
```js{}[nuxt.config.ts]
54-
export default defineNuxtConfig({
55-
routeRules: {
56-
'/custom-route': {
57-
security: {
58-
rateLimiter: false
59-
}
60-
}
61-
}
62-
})
63-
```
9+
The module by default will register **global** middleware and route roules to make your application more secure. You can also modify or disable any of middlewares/routes or your project cannot use them (i.e. some Statically Generated websites will not be able to use middlewares).
6410

6511
## Types
6612

@@ -83,7 +29,7 @@ interface ModuleOptions {
8329
}
8430
```
8531

86-
All above `ModuleOptions` are explained in more details in the [next chapter](/security/headers)
32+
All above `ModuleOptions` are explained in more details in the next sections.
8733

8834
## Default
8935

docs/content/1.documentation/1.getting-started/3.headers.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Nuxt Security automatically registers HTTP security headers.
44

55
---
66

7+
:ellipsis{right=0px width=75% blur=150px}
8+
79
A set of **global** Nuxt `routeRules` that will add appropriate security headers to your response that will make your application more secure by default. All headers can be overriden by using the module configuration. Check out all the available types [here](https://github.com/Baroshem/nuxt-security/blob/main/src/types.ts).
810

911
It will help you solve [this](https://cheatsheetseries.owasp.org/cheatsheets/Nodejs_Security_Cheat_Sheet.html#use-appropriate-security-headers) security problem.
@@ -39,7 +41,7 @@ export default defineNuxtConfig({
3941
```
4042

4143
::alert{type="warning"}
42-
When using `routeRules`, make sure to use the proper HTTP Header names like `Cross-Origin-Embedder-Policy` instead of `crossOriginEmbedderPolicy`.
44+
When using `routeRules`, make sure to use the proper HTTP Header names like `Cross-Origin-Embedder-Policy` instead of `crossOriginEmbedderPolicy` and to not nset the headers inside `security`. These headers are handled by Nuxt and you can check more [here](https://nuxt.com/docs/guide/concepts/rendering#hybrid-rendering).
4345
::
4446

4547
## Disabling header

docs/content/1.documentation/1.getting-started/4.middleware.md

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Nuxt Security automatically registers middleware to handle several security issu
44

55
---
66

7+
:ellipsis{right=0px width=75% blur=150px}
8+
79
A set of **global** Nuxt `routeRules` that will add appropriate security middleware that will make your application more secure by default. Every middleware can be overriden by using the module configuration.
810

911
## Global configuration
@@ -38,6 +40,10 @@ export default defineNuxtConfig({
3840
})
3941
```
4042

43+
::alert{type="warning"}
44+
When using `routeRules`, make sure to add middleware inside of `security` in certain route rule. This is a custom NuxtSecurity addition that does not exists in core Nuxt.
45+
::
46+
4147
## Disabling middleware
4248

4349
To disable given middleware, pass `false` .

docs/content/1.documentation/2.headers/1.csp.md

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
---
66

7+
:ellipsis{right=0px width=75% blur=150px}
8+
79
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.
810

911
::alert{type="info"}

docs/content/1.documentation/2.headers/2.permissions-policy.md

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
---
66

7+
:ellipsis{right=0px width=75% blur=150px}
8+
79
Permissions Policy provides mechanisms for web developers to explicitly declare what functionality can and cannot be used on a web site. You define a set of "policies" that restrict what APIs the site's code can access or modify the browser's default behavior for certain features.
810

911
::alert{type="info"}

docs/content/1.documentation/2.headers/3.other.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
---
66

7+
:ellipsis{right=0px width=75% blur=150px}
78

89
## Cross-Origin-Embedder-Policy
910

docs/content/1.documentation/3.middleware/1.rate-limiter.md

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
---
66

7+
:ellipsis{right=0px width=75% blur=150px}
8+
79
Stores ip addresses of a requests in lru-cache and will throw an `429 Too Many Requests` error when there will be too many requests. Based on <https://unstorage.unjs.io/>
810

911
::alert{type="warning"}

docs/content/1.documentation/3.middleware/2.request-size-limiter.md

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
---
66

7+
:ellipsis{right=0px width=75% blur=150px}
8+
79
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.
810

911
::alert{type="info"}

docs/content/1.documentation/3.middleware/3.xss-validator.md

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
---
66

7+
:ellipsis{right=0px width=75% blur=150px}
8+
79
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>
810

911
::alert{type="info"}

docs/content/1.documentation/3.middleware/4.cors-handler.md

+4
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@
44

55
---
66

7+
:ellipsis{right=0px width=75% blur=150px}
8+
79
This middleware will help you set your CORS options and it is based on built in [H3 CORS](https://github.com/unjs/h3) functionality
810

911
::alert{type="info"}
1012
ℹ Read more about Cross Origin Resource Sharing [here](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS).
1113
::
1214

15+
Testing CORS configuration can be done by running one application with NuxtSecurity enabled and creating a second application (that is running on a different port) that will send a request to the first app. Then, a CORS error could be easily observed that proves that CORS is working as expected.
16+
1317
## Usage
1418

1519
This middleware is enabled globally by default. You can customize it both globally and per route like following:

docs/content/1.documentation/3.middleware/5.allowed-methods-restricter.md

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
---
66

7+
:ellipsis{right=0px width=75% blur=150px}
8+
79
This middleware works by default for `*` HTTP Methods and will throw an `405 Method Not Allowed` error when the there will be a request sent with an HTTP Method that is not allowed.
810

911
::alert{type="info"}

docs/content/1.documentation/3.middleware/6.basic-auth.md

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
---
66

7+
:ellipsis{right=0px width=75% blur=150px}
8+
79
This middleware will implement Basic Auth in your application. Only users with correct credentials passed to the browser prompt will be able to see the application. Others will be automatically rejected.
810

911
::alert{type="info"}

docs/content/1.documentation/3.middleware/7.csrf.md

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
---
66

7+
:ellipsis{right=0px width=75% blur=150px}
8+
79
Cross-Site Request Forgery (CSRF) is an attack that forces an end user to execute unwanted actions on a web application in which they’re currently authenticated. With a little help of social engineering (such as sending a link via email or chat), an attacker may trick the users of a web application into executing actions of the attacker’s choosing. If the victim is a normal user, a successful CSRF attack can force the user to perform state changing requests like transferring funds, changing their email address, and so forth. If the victim is an administrative account, CSRF can compromise the entire web application.
810

911
::alert{type="info"}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Hide `X-Powered-By`
2+
3+
:badge[Enabled]{type="success"} Avoid leaking info about your framework.
4+
5+
---
6+
7+
:ellipsis{right=0px width=75% blur=150px}
8+
9+
`X-Powered-By` header is used to inform what technology is used in the server side. This is an unnecessary header causing information leakage, so it should be removed from your application.
10+
11+
::alert{type="info"}
12+
ℹ Read more about it [here](https://cheatsheetseries.owasp.org/cheatsheets/Nodejs_Security_Cheat_Sheet.html#use-appropriate-security-headers).
13+
::
14+
15+
Fortunately, `nuxt-security` module hides this header by default so your application is not leaking this information in the response headers.
16+
17+
However, if you prefer not to have this changed, you can always disable this functionality from the module configuration (which is not recommended but possible) like the following:
18+
19+
```js{}[nuxt.config.ts]
20+
export default defineNuxtConfig({
21+
modules: ['nuxt-security'],
22+
security: {
23+
hidePoweredBy: false
24+
}
25+
})
26+
```

docs/content/1.documentation/4.advanced/1.utils.md docs/content/1.documentation/4.utils/2.remove-console-loggers.md

+3-24
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,10 @@
1-
# Utils
1+
# Remove Console Loggers
22

3-
:badge[Enabled]{type="success"} Additional utilies that help secure your app.
3+
:badge[Enabled]{type="success"} Avoid shipping console.logs and debuggers into production.
44

55
---
66

7-
## Hide `X-Powered-By` header
8-
9-
`X-Powered-By` header is used to inform what technology is used in the server side. This is an unnecessary header causing information leakage, so it should be removed from your application.
10-
11-
::alert{type="info"}
12-
ℹ Read more about it [here](https://cheatsheetseries.owasp.org/cheatsheets/Nodejs_Security_Cheat_Sheet.html#use-appropriate-security-headers).
13-
::
14-
15-
Fortunately, `nuxt-security` module hides this header by default so your application is not leaking this information in the response headers.
16-
17-
However, if you prefer not to have this changed, you can always disable this functionality from the module configuration (which is not recommended but possible) like the following:
18-
19-
```js{}[nuxt.config.ts]
20-
export default defineNuxtConfig({
21-
modules: ['nuxt-security'],
22-
security: {
23-
hidePoweredBy: false
24-
}
25-
})
26-
```
27-
28-
## Remove Console Loggers
7+
:ellipsis{right=0px width=75% blur=150px}
298

309
By default, your application will allow log all activity in the browser when you write `console.log(user)` that can lead to some unwanted information leakage.
3110

docs/content/1.documentation/4.advanced/2.good-practices.md docs/content/1.documentation/5.advanced/2.good-practices.md

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Learn how you can make your app even more secure.
44

55
---
66

7+
:ellipsis{right=0px width=75% blur=150px}
8+
79
## Only return what is necessary
810

911
If you just need a certain field of an object, you should only return the specific fields required. In other words, if you only need to list names of the users available, you are not returning their email addresses or credit card numbers in addition to their full names.

docs/content/1.documentation/5.community/1.content.md

-13
This file was deleted.

0 commit comments

Comments
 (0)