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
{{ message }}
This repository was archived by the owner on Dec 12, 2023. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+9-7Lines changed: 9 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,7 +57,7 @@ The `nuxt-session` library provide many helpers to interact with the session fro
57
57
- ✔️ Configurable session endpoints out of the box:
58
58
- `GET /api/session`: Get the current session
59
59
- `DELETE /api/session`: Delete the current session
60
-
- `POST /api/session`: Overwrite the current session data
60
+
- `POST /api/session`: Overwrite the current session data
61
61
- `PATCH /api/session`: Add to the current session data
62
62
- ✔️ Storage via [unjs/unstorage](https://github.com/unjs/unstorage) - use memory, redis, fs, cloudflare-kv, ... to store your session data
63
63
- ✔️ Automatic session and storage cleanup on expiry
@@ -115,10 +115,10 @@ Allowing alteration of session-data with arbitrary data provided by the client (
115
115
116
116
On the client-side you can use the session like this:
117
117
```ts
118
-
const {
119
-
session,
118
+
const {
119
+
session,
120
120
refresh,
121
-
remove,
121
+
remove,
122
122
reset,
123
123
update,
124
124
overwrite
@@ -195,7 +195,7 @@ In theory you can manipulate this data on the server side if you want to. If you
195
195
196
196
### Storage Backends
197
197
198
-
`nuxt-session` allows you to use different storage backends. A storage backend is something like your server memory, a redis database, the file-system of your server, ... Supporting these backend is possible by using [unjs/unstorage](https://github.com/unjs/unstorage) for storage management. This library connects to the different backends it supports with a unified interface.
198
+
`nuxt-session` allows you to use different storage backends. A storage backend is something like your server memory, a redis database, the file-system of your server, ... Supporting these backend is possible by using [unjs/unstorage](https://github.com/unjs/unstorage) for storage management. This library connects to the different backends it supports with a unified interface.
199
199
200
200
You can configure the storage backend using the `session.session.storageOptions` configuration option of the `nuxt-session` module. By default `memory` is used to store the sessions. This has some advantages like speed and easy setup, but some disadvantages like missing persistency (if your server crashes, the sessions are gone!) and possible exploits like setting millions of sessions trying to exhaust your server-memory or saving large amounts of data into the session that your server cannot handle.
201
201
@@ -219,6 +219,8 @@ Here's what the full _default_ module configuration looks like:
219
219
cookieSameSite: 'lax',
220
220
// In-memory storage is used (these are `unjs/unstorage` options)
221
221
storageOptions: {}
222
+
// The request-domain is strictly used for the cookie, no sub-domains allowed
223
+
domain: null
222
224
},
223
225
api: {
224
226
// The API is enabled
@@ -231,7 +233,7 @@ Here's what the full _default_ module configuration looks like:
231
233
}
232
234
```
233
235
234
-
### Security
236
+
### Security
235
237
236
238
This section mostly contains a list of possible security problems and how to mitigate (some) of them. Note that the below flaws exist with many libraries and frameworks we use in our day-to-day when building and working with APIs. E.g., your vanilla-nuxt-app is not safe of some of them like the client sending malicious data. Missing in the below list are estimates of how likely it is that one of the list-items may occur and what impact it will have on your app. This is because that heavily depends on:
237
239
- your app: Are you building a fun project? A proof of concept? The next fort-nox money management app?
@@ -251,7 +253,7 @@ Without further ado, here's some attack cases you can consider and take action a
251
253
- use `redis` as a storage backend and set data to expire automatically
252
254
3. guessing correct session ids
253
255
- problems: session data can leak
254
-
- possible mitigations:
256
+
- possible mitigations:
255
257
- disable reading of data on the client side by disabling the api or setting `api: { methods: [] }`
256
258
- increase the default sessionId length (although with `64` characters it already is quite long, in 2022)
0 commit comments