Commit Graph

2455 Commits

Author SHA1 Message Date
Iain Collins
c55cb526f7 Update about.md 2020-05-23 01:56:31 +01:00
Iain Collins
70a728f15b Update documentation 2020-05-23 01:51:31 +01:00
Iain Collins
e7c9c844dc Update document site (#149) 2020-05-23 00:14:26 +02:00
Iain Collins
cf8e6980be Simplify database configuration
* Now accepts 'database' as an option as an alterantive to 'adapter'.
* If specified, 'database' can be a string or object and will load the default adapter.
* The 'adapter' option is still valid, and overrides the 'database' option.

 If neither option is specified, displays console error and web error page.
2020-05-21 20:51:58 +01:00
Iain Collins
7cd537d58d Customise website theme and homepage 2020-05-21 20:21:56 +01:00
ndo@ndo3
7ad11f73cd fix: quick typo 2020-05-21 12:34:43 +02:00
Nico Domino
82ac943e3e update: docs formatting / spelling / small stuff (#138) 2020-05-20 22:26:38 +02:00
Iain Collins
420bb9a74c Fix default session expiry time
Due to typo, was setting default expiry time to 30 hours, instead of 30 days.

This also made update session  behave incorrectly.
2020-05-20 18:39:28 +01:00
Iain Collins
4c32727b37 Refactor urlPrefix as baseURL
The name baseURL (and basePath) are exposed as options.

As they are more more widely used than urlPrefix and pathPrefix I've renamed them globally.
2020-05-20 18:39:28 +01:00
Iain Collins
339f618685 Refactor urlPrefix as baseURL
The name baseURL (and basePath) are exposed as options.

As they are more more widely used than urlPrefix and pathPrefix I've renamed them globally.
2020-05-20 18:10:37 +01:00
Lori Karikari
2a8337e67c Provider docs cleanup (#135)
* some initial cleanup

* cleaned up the config table

* added FB and fixed some alignments
2020-05-19 20:54:52 +02:00
Iain Collins
bd50714759 Merge branch 'master' of github.com:iaincollins/next-auth 2020-05-19 18:38:43 +01:00
Iain Collins
db9ef09d1d Fix edit URL in docs 2020-05-19 18:38:36 +01:00
Merijn
3bb4e0ca6f Fix parameter params 2020-05-19 14:16:47 +01:00
Iain Collins
b4886295ac Rename compound id field in account model
This constraint provides a cross-platform way of enforcing that a given oAuth account can only be associated with a single user, while allowing a user to link multiple oAuth accounts (and use any account they own to sign in).
2020-05-19 03:37:27 +01:00
Iain Collins
ef455dcf06 Add more information to contributing guide
Added the detailed steps on to set up an environment locally from #105
2020-05-19 02:39:28 +01:00
Iain Collins
5afa4f6e2b Refactor adapter logic
* Refactored adapter, with less redundant logic
* Removed logic from models
* Added email verification expiry support (defaults to 24 hours)
* Refactored session expiry handling and unified it with how email expiry works
* Default session expiry is still 30 days
* Now only updates expiry for a session at most once every 24 hours by default, to reduce writes to database
* Email verification max age, session max age and how often sessions are updated (to reduce database writes) are all simple options now
* Invalid sessionTokens are now deleted from the client
* Email verfication messages are now deleted once used (or when expired)
* Debug output is now an option (set `debug: true` to enable)
* Removed confusing options / callback from default adapter (except for passing in custom models/schemas)
* Adapter can now access all next-auth options, to make configuration easier
2020-05-19 02:08:10 +01:00
Iain Collins
50678d73bd Allow sessionToken cookie options to override defaults
This makes it possible to configure  session tokens to be deleted when the browser window is closed if desired.

Session expiry can now be treated as an optional field (but is always set and enforced by default).
2020-05-18 19:04:36 +01:00
Iain Collins
6d7066e4db Fix bug in session route
Accidentally included set cookie of a conditional it needs to be in.
2020-05-18 18:03:26 +01:00
Iain Collins
52eb11b385 Add session expiry logic
* By default, sessions are 30 day 'rolling sessions' and the timestamp for when they expire is extended when they are accessed to keep them alive.
* When sessions expire (ie after 30 days of inactivity), session object returns empty (as if there is no session) and users must sign in in again.
* Cleaning up old sessions from the database is not currently handled by the default adapter, but I do intend to add some logic to do this (added @TODO).
* The session expiry date can be changed by passing a custom updateSession() callback handler function in the options to the default adapter.

Using a custom `updateSession()` method with the default adapter, it is possible to specify other behaviour:

e.g.

* Disable rolling sessions (e.g. force a new login every X days).
* Create a session expiry date far into the future on initial sign in, so that they effectively never expire.
* Set a decently long max expiry time (e.g. 90+ days) but only actually update the session expiry time if the current expiry time is < 30 days; so that sessions stay valid for 30 days (and at most 90 days of inactivity) so that idle sessions are valid for at least 30 days (and maybe longer) but you don't need to write to your session database as often (useful if slow/expensive).

Note: Adapter options are passed as second option to the default adapter (the first option being the DB connection details). This is probably confusing and might be a design mistake.

const adapter = Adapter.Default({ /* database object * /}, {
  updateSession: async (session, isNewSession) => {
    // 1st arg is the current session (or null) so it's easy to check current
    // expiry date, get user specific info, etc.
    // 2nd arg is true if this is a brand new session.
    //
    // Function should return an ISO date (e.g. toISOString) or false/null to
    // prevent an update from being applied; but should always return a session
    // if isNewSession is set or the sign in will fail.
  }
})

Relying on on Adapter options is a little obtuse / confusing and so I'm considering it an 'advanced option' right now. In future, we might change how session expiry dates and behaviour is set to make it easier.

Note: There are some other updates in this PR, that's just from the linter and some improvements to formatting of contributing guide.
2020-05-18 17:49:32 +01:00
Nico Domino
b176c15405 Docs - Add search (#129) 2020-05-18 15:10:40 +02:00
Iain Collins
021fdbcf1b Update contributing docs 2020-05-18 09:15:02 +01:00
Lori Karikari
d7d9988cd8 Add auth0 (#126)
* added Auth0 and updated docs

* changed to proper Auth0 urls
2020-05-17 23:28:18 +02:00
Nico Domino
e8baee1774 Another Docs Update (#124) 2020-05-17 23:21:14 +02:00
Lori Karikari
79179dad71 added Auth0 and updated docs (#125) 2020-05-17 23:21:02 +02:00
Iain Collins
c8de8a1182 Fix editUrl in docs
I think I broke this earlier by mistake
2020-05-17 22:08:14 +01:00
ndo@ndo3
a2cfcef0aa update: docs site 2020-05-17 22:05:27 +01:00
Lori
28d220a42b added Facebook 2020-05-17 20:57:16 +01:00
Iain Collins
26a8b20459 Bump version number
Debugging issue with deployment of docs site.
2020-05-17 20:42:16 +01:00
Iain Collins
84e0ddf241 Fix issue with docusaurus config on now.sh
Although previous config worked locally, it turns out it isn't compatible with now.sh.

It turns out when deploying from a subdir (like 'www') on now.sh the contents of the parent directory isn't avalible.
2020-05-17 20:30:56 +01:00
Iain Collins
6e3a6ba287 Update docs and website dir structure
* Now has 'www' directory at root level for the website (was 'docs').
* The 'docs' directory now only contains Markdown docs.
* Docusarus config looks in '../docs' for the docs.

This is deployed with now.sh to https://next-auth-docs.now.sh
2020-05-17 20:13:54 +01:00
Nico Domino
d6e7b09ff7 Update docusaurus.js to work with now.sh again 2020-05-17 19:01:50 +02:00
Iain Collins
daca296df4 Remove .vscode dir I commited by mistake 2020-05-17 17:49:24 +01:00
Iain Collins
dbab5a3505 Refactor to remove oauth cruft
Removed unesseary branching for unused oauth code.
2020-05-17 17:45:00 +01:00
Iain Collins
8aa4045651 Force email to lowercase in all flows 2020-05-17 17:45:00 +01:00
ndo@ndo3
eb9561edab chore: cleanup markdown + CNAME 2020-05-17 17:45:00 +01:00
ndo@ndo3
332182a67f add: CNAME 2020-05-17 17:45:00 +01:00
ndo@ndo3
d7a2cde57e update: sidebar labels 2020-05-17 17:45:00 +01:00
ndo@ndo3
bb04645a93 update: package.json 2020-05-17 17:45:00 +01:00
ndo@ndo3
d25493ae79 add: docusaurus docs 2020-05-17 17:45:00 +01:00
Lori
8522628a11 removed incomplete custom email, added some more links and cleanup 2020-05-17 17:45:00 +01:00
Lori
875ecaeb06 first draft 2020-05-17 17:45:00 +01:00
Iain Collins
25c83b2914 Update session.js 2020-05-17 17:45:00 +01:00
Iain Collins
8a516904b8 Force email to lowercase in all flows 2020-05-17 17:45:00 +01:00
Iain Collins
df4c71496b Fix bugs with sign in flow and error handling 2020-05-17 17:45:00 +01:00
Iain Collins
026bef6f60 Improve error handling
* Better error handling, more specific messages.
* Async email option has been removed as was problematic on serverless.
* Refactored email sign in so that sending emails is now handled by the email provider.
* How email configuration works is now more customimzable - and cleanly seperated from  database logic.
* Now possible to define logic for async email (e.g. pass messages to a queue) or use any email provider or API.
2020-05-17 17:45:00 +01:00
Iain Collins
2b168e183b Improve error messages 2020-05-17 17:45:00 +01:00
Iain Collins
c86ea5e9dc Refactor sign in; make async email optional
* Email providers can now set  the option 'async' to 'true' to send emails AFTER displaying confirmation page, or to 'false' send emails BEFORE returning to the user. Defaults to false.

Setting it to true is faster for the user, but is hard to debug as it's not easy to know if it worked or not.

* Fixed bug with unsubscribe option.

* Moved oAuth and Email signin handlers together in `lib` dir.
2020-05-17 17:45:00 +01:00
Iain Collins
966577fc02 Improve email sign in flow 2020-05-17 17:45:00 +01:00
Iain Collins
d0d3af5f12 Bump version to beta 23 2020-05-17 17:45:00 +01:00