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
For less serious issues (e.g. RFC compliance for unsupported flows or potential issues that may cause a problem future or default behaviour / options) it is appropriate to submit these these publically as bug reports or feature requests or to raise a question to open a discussion around them.
(See also: <ahref="/configuration/providers">Providers</a>)
30
29
</p>
31
30
32
-
33
31
NextAuth.js also supports email for passwordless sign in, which is useful for account recovery or for people who are not able to use an account with the configured OAuth services (e.g. due to service outage, account suspension or otherwise becoming locked out of an account).
34
32
35
33
You can also use a custom based provider to support signing in with a username and password stored in an external database and/or using two factor authentication.
@@ -58,7 +56,6 @@ NextAuth.js is designed as a secure, confidential client and implements a server
58
56
59
57
It is not intended to be used in native applications on desktop or mobile applications, which typically implement public clients (e.g. with client / secrets embedded in the application).
60
58
61
-
62
59
### Is NextAuth.js supporting TypeScript?
63
60
64
61
Yes! Check out the [TypeScript docs](/getting-started/typescript)
@@ -83,26 +80,25 @@ If you are using a database with NextAuth.js, you can still explicitly enable JS
83
80
84
81
### Should I use a database?
85
82
86
-
* Using NextAuth.js without a database works well for internal tools - where you need to control who is able to sign in, but when you do not need to create user accounts for them in your application.
83
+
- Using NextAuth.js without a database works well for internal tools - where you need to control who is able to sign in, but when you do not need to create user accounts for them in your application.
87
84
88
-
* Using NextAuth.js with a database is usually a better approach for a consumer facing application where you need to persist accounts (e.g. for billing, to contact customers, etc).
85
+
- Using NextAuth.js with a database is usually a better approach for a consumer facing application where you need to persist accounts (e.g. for billing, to contact customers, etc).
89
86
90
87
### What database should I use?
91
88
92
89
Managed database solutions for MySQL, Postgres and MongoDB (and compatible databases) are well supported from cloud providers such as Amazon, Google, Microsoft and Atlas.
93
90
94
91
If you are deploying directly to a particular cloud platform you may also want to consider serverless database offerings they have (e.g. [Amazon Aurora Serverless on AWS](https://aws.amazon.com/rds/aurora/serverless/)).
95
92
96
-
97
93
---
98
94
99
-
## Security
95
+
## Security
100
96
101
97
### I think I've found a security problem, what should I do?
102
98
103
99
Less serious or edge case issues (e.g. queries about compatibility with optional RFC specifications) can be raised as public issues on GitHub.
104
100
105
-
If you discover what you think may be a potentially serious security problem, please contact a core team member via a private channel (e.g. via email to [email protected]) or raise a public issue requesting someone get in touch with you via whatever means you prefer for more details.
101
+
If you discover what you think may be a potentially serious security problem, please contact a core team member via a private channel (e.g. via email to [email protected] or [email protected] and [email protected]) or raise a public issue requesting someone get in touch with you via whatever means you prefer for more details.
106
102
107
103
### What is the disclosure policy for NextAuth.js?
108
104
@@ -165,60 +161,60 @@ Ultimately if your request is not accepted or is not actively in development, yo
165
161
166
162
---
167
163
168
-
## JSON Web Tokens
164
+
## JSON Web Tokens
169
165
170
166
### Does NextAuth.js use JSON Web Tokens?
171
167
172
168
NextAuth.js supports both database session tokens and JWT session tokens.
173
169
174
-
* If a database is specified, database session tokens will be used by default.
175
-
* If no database is specified, JWT session tokens will be used by default.
170
+
- If a database is specified, database session tokens will be used by default.
171
+
- If no database is specified, JWT session tokens will be used by default.
176
172
177
173
You can also choose to use JSON Web Tokens as session tokens with using a database, by explicitly setting the `session: { jwt: true }` option.
178
174
179
175
### What are the advantages of JSON Web Tokens?
180
176
181
177
JSON Web Tokens can be used for session tokens, but are also used for lots of other things, such as sending signed objects between services in authentication flows.
182
178
183
-
* Advantages of using a JWT as a session token include that they do not require a database to store sessions, this can be faster and cheaper to run and easier to scale.
179
+
- Advantages of using a JWT as a session token include that they do not require a database to store sessions, this can be faster and cheaper to run and easier to scale.
184
180
185
-
* JSON Web Tokens in NextAuth.js are secured using cryptographic signing (JWS) by default and it is easy for services and API endpoints to verify tokens without having to contact a database to verify them.
181
+
- JSON Web Tokens in NextAuth.js are secured using cryptographic signing (JWS) by default and it is easy for services and API endpoints to verify tokens without having to contact a database to verify them.
186
182
187
-
* You can enable encryption (JWE) to store include information directly in a JWT session token that you wish to keep secret and use the token to pass information between services / APIs on the same domain.
183
+
- You can enable encryption (JWE) to store include information directly in a JWT session token that you wish to keep secret and use the token to pass information between services / APIs on the same domain.
188
184
189
-
* You can use JWT to securely store information you do not mind the client knowing even without encryption, as the JWT is stored in a server-readable-only-token so data in the JWT is not accessible to third party JavaScript running on your site.
185
+
- You can use JWT to securely store information you do not mind the client knowing even without encryption, as the JWT is stored in a server-readable-only-token so data in the JWT is not accessible to third party JavaScript running on your site.
190
186
191
187
### What are the disadvantages of JSON Web Tokens?
192
188
193
-
* You cannot as easily expire a JSON Web Token - doing so requires maintaining a server side blocklist of invalid tokens (at least until they expire) and checking every token against the list every time a token is presented.
189
+
- You cannot as easily expire a JSON Web Token - doing so requires maintaining a server side blocklist of invalid tokens (at least until they expire) and checking every token against the list every time a token is presented.
194
190
195
191
Shorter session expiry times are used when using JSON Web Tokens as session tokens to allow sessions to be invalidated sooner and simplify this problem.
196
192
197
193
NextAuth.js client includes advanced features to mitigate the downsides of using shorter session expiry times on the user experience, including automatic session token rotation, optionally sending keep alive messages to prevent short lived sessions from expiring if there is an window or tab open, background re-validation, and automatic tab/window syncing that keeps sessions in sync across windows any time session state changes or a window or tab gains or loses focus.
198
194
199
-
* As with database session tokens, JSON Web Tokens are limited in the amount of data you can store in them. There is typically a limit of around 4096 bytes per cookie, though the exact limit varies between browsers, proxies and hosting services. If you want to support most browsers, then do not exceed 4096 bytes per cookie. If you want to save more data, you will need to persist your sessions in a database (Source: [browsercookielimits.iain.guru](http://browsercookielimits.iain.guru/))
195
+
- As with database session tokens, JSON Web Tokens are limited in the amount of data you can store in them. There is typically a limit of around 4096 bytes per cookie, though the exact limit varies between browsers, proxies and hosting services. If you want to support most browsers, then do not exceed 4096 bytes per cookie. If you want to save more data, you will need to persist your sessions in a database (Source: [browsercookielimits.iain.guru](http://browsercookielimits.iain.guru/))
200
196
201
197
The more data you try to store in a token and the more other cookies you set, the closer you will come to this limit. If you wish to store more than ~4 KB of data you're probably at the point where you need to store a unique ID in the token and persist the data elsewhere (e.g. in a server-side key/value store).
202
198
203
-
* Data stored in an encrypted JSON Web Token (JWE) may be compromised at some point.
199
+
- Data stored in an encrypted JSON Web Token (JWE) may be compromised at some point.
204
200
205
201
Even if appropriately configured, information stored in an encrypted JWT should not be assumed to be impossible to decrypt at some point - e.g. due to the discovery of a defect or advances in technology.
206
202
207
203
Avoid storing any data in a token that might be problematic if it were to be decrypted in the future.
208
204
209
-
* If you do not explicitly specify a secret for NextAuth.js, existing sessions will be invalidated any time your NextAuth.js configuration changes, as NextAuth.js will default to an auto-generated secret.
205
+
- If you do not explicitly specify a secret for NextAuth.js, existing sessions will be invalidated any time your NextAuth.js configuration changes, as NextAuth.js will default to an auto-generated secret.
210
206
211
207
If using JSON Web Token you should at least specify a secret and ideally configure public/private keys.
212
208
213
209
### Are JSON Web Tokens secure?
214
210
215
211
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).
216
212
217
-
* JSON Web Tokens in NextAuth.js use JWS and are signed using HS512 with an auto-generated key.
213
+
- JSON Web Tokens in NextAuth.js use JWS and are signed using HS512 with an auto-generated key.
218
214
219
-
* 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.
215
+
- 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.
220
216
221
-
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).
217
+
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).
222
218
223
219
NextAuth.js will generate keys for you, but this will generate a warning at start up.
224
220
@@ -228,14 +224,14 @@ Using explicit public/private keys for signing is strongly recommended.
228
224
229
225
NextAuth.js includes a largely complete implementation of JSON Object Signing and Encryption (JOSE):
230
226
231
-
*[RFC 7515 - JSON Web Signature (JWS)](https://tools.ietf.org/html/rfc7515)
232
-
*[RFC 7516 - JSON Web Encryption (JWE)](https://tools.ietf.org/html/rfc7516)
233
-
*[RFC 7517 - JSON Web Key (JWK)](https://tools.ietf.org/html/rfc7517)
234
-
*[RFC 7518 - JSON Web Algorithms (JWA)](https://tools.ietf.org/html/rfc7518)
235
-
*[RFC 7519 - JSON Web Token (JWT)](https://tools.ietf.org/html/rfc7519)
227
+
-[RFC 7515 - JSON Web Signature (JWS)](https://tools.ietf.org/html/rfc7515)
228
+
-[RFC 7516 - JSON Web Encryption (JWE)](https://tools.ietf.org/html/rfc7516)
229
+
-[RFC 7517 - JSON Web Key (JWK)](https://tools.ietf.org/html/rfc7517)
230
+
-[RFC 7518 - JSON Web Algorithms (JWA)](https://tools.ietf.org/html/rfc7518)
231
+
-[RFC 7519 - JSON Web Token (JWT)](https://tools.ietf.org/html/rfc7519)
236
232
237
233
This incorporates support for:
238
234
239
-
*[RFC 7638 - JSON Web Key Thumbprint](https://tools.ietf.org/html/rfc7638)
0 commit comments