Skip to content
This repository was archived by the owner on Jul 6, 2022. It is now read-only.

Commit 07ba887

Browse files
authored
feat: add info about cookie chunking (#100)
1 parent b0f5c92 commit 07ba887

2 files changed

Lines changed: 4 additions & 8 deletions

File tree

docs/configuration/options.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ session: {
116116

117117
JSON Web Tokens can be used for session tokens if enabled with `session: { jwt: true }` option. JSON Web Tokens are enabled by default if you have not specified a database.
118118

119-
By default JSON Web Tokens are signed (JWS) but not encrypted (JWE), as JWT encryption adds additional overhead and comes with some caveats. You can enable encryption by setting `encryption: true`.
119+
By default JSON Web Tokens are not signed (JWS) but are encrypted (JWE).
120120

121121
#### JSON Web Token Options
122122

@@ -405,8 +405,6 @@ When set to `true` (the default for all site URLs that start with `https://`) th
405405

406406
This option defaults to `false` on URLs that start with `http://` (e.g. `http://localhost:3000`) for developer convenience.
407407

408-
You can manually set this option to `false` to disable this security feature and allow cookies to be accessible from non-secured URLs (this is not recommended).
409-
410408
:::note
411409
Properties on any custom `cookies` that are specified override this option.
412410
:::
@@ -424,6 +422,8 @@ Setting this option to _false_ in production is a security risk and may allow se
424422

425423
#### Description
426424

425+
Cookies in NextAuth.js are chunked by default, meaning that once they reach the 4kb limit, we will create a new cookie with the `.{number}` suffix and reassemble the cookies in the correct order when parsing / reading them. This was introduced to avoid size constraints which can occur when users want to store additional data in their sessionToken, for example.
426+
427427
You can override the default cookie names and options for any of the cookies used by NextAuth.js.
428428

429429
This is an advanced option and using it is not recommended as you may break authentication or introduce security flaws into your application.

docs/faq.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -356,11 +356,7 @@ JSON Web Tokens can be used for session tokens, but are also used for lots of ot
356356
</summary>
357357
<p>
358358

359-
By default tokens are signed (JWS) but not encrypted (JWE), as encryption adds additional overhead and reduces the amount of space available to store data (total cookie size for a domain is limited to 4KB).
360-
361-
- JSON Web Tokens in NextAuth.js use JWS and are signed using HS512 with an auto-generated key.
362-
363-
- If encryption is enabled by setting `jwt: { encryption: true }` option then the JWT will _also_ use JWE to encrypt the token, using A256GCM with an auto-generated key.
359+
By default tokens are not signed (JWS) but are encrypted (JWE). Since v4 we have implemented cookie chunking so that cookies over the 4kb limit get split and reassembled upon parsing.
364360

365361
You can specify other valid algorithms - [as specified in RFC 7518](https://tools.ietf.org/html/rfc7517) - with either a secret (for symmetric encryption) or a public/private key pair (for a symmetric encryption).
366362

0 commit comments

Comments
 (0)