Commit Graph

2126 Commits

Author SHA1 Message Date
Nico Domino
7b38af81cf Update README - Fix Typos 2020-05-26 21:48:25 +02:00
Iain Collins
401df2c177 Update Getting Started guide 2020-05-26 19:44:13 +01:00
Iain Collins
ffd9691cd0 Update docs for database and secret options 2020-05-26 19:44:13 +01:00
Iain Collins
e7ae32f618 Update www/docs/configuration.md 2020-05-26 19:39:28 +01:00
ndo@ndo1
97fadb0d9f fix: cleanup code example 2020-05-26 19:39:28 +01:00
ndo@ndo1
86f072bf4b add: docs for custom signin page 2020-05-26 19:39:28 +01:00
Iain Collins
981984b562 Improve database URI handling
* Fix bug in parser (.query -> search)
* Comments to explain what is going on
* Fallback to TypeORM parser
2020-05-26 17:48:04 +01:00
Iain Collins
1e9053d879 Add support for passing URL to 'database' option
* Database configuration now only needs a single line!
* You can still specify options using query string parameters.
* You can still specify an object, so this is not a breaking change.
2020-05-26 13:19:47 +01:00
Iain Collins
cb1ce73c92 Update title of documentation homepage 2020-05-26 13:19:47 +01:00
Iain Collins
93054578c9 Update README.md 2020-05-26 02:08:03 +01:00
Iain Collins
d112800b98 Add custom pages
Now supports 'pages' option, which can be any URL.

If specified, these replace the built in pages.

Example usage:

pages: {
  signin: 'https://example.com/signin',
  signout: 'https://example.com/signout',
  checkEmail: 'https://example.com/check-email',
  error: 'https://example.com/error'
}
2020-05-26 01:02:02 +01:00
Iain Collins
c8bf342d8b Fix sqlite support 2020-05-25 21:43:50 +01:00
Iain Collins
63ceb1a260 Don't lookup session if session token empty 2020-05-25 21:24:45 +01:00
Iain Collins
ca519b69ce Fix schema and queries for mongodb 2020-05-25 21:24:45 +01:00
Iain Collins
2f16d8448d Fix issues with database; make it easier to test
These changes fix compatibility issues with common SQL databases including MySQL, MariaDB and Postgres.

* Fixes #147 - datetime now ANSI SQL timestamp
* Fixes #160 - AccessToken and RefreshToken type change from varchar to text
* Adds Docker Compose files to make it easier to test database integration.

TODO:

* Update documentation with configuration examples and latest compatibility info
* Create DB URI parser (currently only object config works)
* Database table/collection name prefix (will default to `next-auth_`)
* MongoDB support

MongoDB has some issues which mean it will require additional work and refactoring to support (while preserving SQL DB support, which is important).

It's going to take some thinking about to get right; MongoDB support might have to be dropped from 2.0 (and follow in a subsequent release) but I'm going to review options and consider the impact before making a call.
2020-05-25 18:15:33 +01:00
Iain Collins
74b334f7ad Fix default exports in entrypoints
Resolves #157
2020-05-25 12:11:35 +01:00
Lachlan Campbell
d5a231f51b Fix typos: directory is called “pages” (#155) 2020-05-24 17:28:55 +02:00
ndo@ndo3
9b24e216fa fix: import statement typo 2020-05-23 17:31:19 +02:00
Lori Karikari
a944870eb2 changed options to params (#154) 2020-05-23 16:32:44 +02:00
Iain Collins
bc6fd4aa32 Bump version number to beta 43 2020-05-23 03:56:54 +01:00
Iain Collins
4a00d5aca5 Fix error when missing email in profile
* Fixes #145
* See also #131

This doesn't allow signing in without an email address, but it handles it gracefully.
2020-05-23 03:55:41 +01:00
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