-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposals for NextAuth 2.0 #14
Comments
To clarify, there is no planned release timeframe for 2.0 yet - and 1.x is will continue to see new feature work before 2.0, as some good feature requests for things like localStrategies and other options have come in that are easy to deal with without any breaking API changes required, so they will likely get priority. |
Some work has already been done by others to add better database support for 1.5 - specifically MySQL support - and we may just share that in the interim, if we can get it documented, ready to share and they agree. For 2.0 though, we are thinking of increasing the number of discrete database calls, with the trade off being they do specific things and ultimately requires less code (and simpler code), especially when interacting with SQL databases. As a result of them being easier to write, it would include built-in support for at least both Mongo DB and MySQL out of the box. This is an example of the sort of methods a DB driver for NextAuth 2.0 would need to support: Feedback welcome! |
I like this path forward, and it confronts my feeling that this project it a bit complex to put in place easily. I have a project I'm starting (about 6 pages in), and thought it may be easier to use the starter auth and copy my stuff in. Thanks for this project, it's looking good! |
Thanks for the feedback! I agree it's too complicated as it is, but am very glad for the feedback I've gotten and issues the existing implementation has raised. I've been focused on making progress on another commercial projects (which uses next-auth) and looking forward to revisiting it for 2.0 soon. |
Hello, @iaincollins are you accepting help with the 2.0 version? I can help with the simpler configuration point. But the 2.0 branch seems like untouched by ~1 year... What are your plans? |
Hi @falleco thank you for asking and for reaching out - and to everyone else for feedback. After a long period of dormancy - mostly due to the evolving nature of Next.js and Now.sh over the last year - I've picked up work on NextAuth 2.0! |
tl;dr Much of this has been done already this week (as of v2.0 beta 10) and the rest is coming soon! Closing this thread, follow the NextAuth 2.0 announcement for updates. |
Proposal for NextAuth 2.0
The following proposal is what is planned for NextAuth 2.0. Some of these features have already made it into 1.5. Others are in progress. It is an active work in progress but there is no fixed ETA yet.
Comments and feedback are welcome.
Updated 29 May, 2018.
Simpler Configuration
The core rationale for NextAuth 2.0 is to make it much simpler to use, so that instead of 3 configuration files all you will need is to use it is to do something like this:
It will include built in support for at least Mongo DB and MySQL and use the connection string to detect database type (e.g. checking if it starts with
mongodb://
ormysql://
).It will still be possible to define your own functions to integrate with another database. Having examples for both an SQL and NoSQL database should make it easy to create adapters for other databases.
New Features
Changes to Session Storage and CSRF Tokens
There are some changes to the way session storage will be handled:
The implementation of Cross Site Request Forgery tokens will switch to the Double Submit Cookie method, which does not require a server side session.
A session in a databases will only be created for a user when they log in, to reduce database load - this also helps provide some protection against trivial Denial of Service attacks.
CSRF will be an option, and it will be possible to set it to null or to explicitly pass a method which can be used to disable it on white listed routes if required.
NextAuth Pages
Built in 'white labeled' pages for displaying a sign in dialog and linking/unlinking accounts.
Built in 'white labeled' pages for callbacks, error handling and email token messages.
These will be the default but you will specify your own URLs if you wished:
## NextAuth Components
We will also expose the components used to make these pages (e.g.
<NextAuth.SignInButton/>
,<NextAuth.SignOutButton/>
), to make it easier to add them to a site.Going further, a basic page will also be exported as
NextAuth.React.Component
to automatically add session data to every page if used in place ofReact.Component
when declaring a page. It will otherwise work exactly like a React page in Next.js.Example
These components will take options like
<NextAuth.SignInButtons className="btn btn-primary">
to allow them to be easily styled. They will be simple HTML elements with perhaps (optional) JavaScript behaviour bound to them.Built in Database support
Bundled strategies for both session and user databases - including as an in-memory DB, Mongo DB and MySQL.
It will still be possible to define your own methods for other session and database stores (and this will be easier than it is now - so it shouldn't matter which SQL or NoSQL DB you are using).
The session and user database stores will not have to be the same database or even the same type of database.
Internally, the functions might change to make this easier, so that instead of general purpose database methods like
update()
andinsert()
they might be named after actions such ascreateUser()
,linkProvider()
,unlinkProvider()
,generateSigninToken()
, etc.This will mean slightly more functions will need to be defined than in 1.x, but they will be explicit in functionality so that they can be more single purpose and easier to adapt to different databases.
If the database type in the connection string is one of the supported types, it will load the appropriate config, connect (and check the table structure if an SQL database, creating tables and columns as required if they don't existing) then return pre-configured strategy so it "just works" out of the box.
NextAuth will of course need to be updated to only start once the promise returned by NextAuth.Functions() and NextAuth.Sessions() had returned
We'd only bundle support for a few simple commonly used strategies - such as Facebook, Twitter and Google, but you'd still be able to define your own for any oAuth provider - the same way they are already configured for NextAuth.
Optional parameters for each Provider will include:
Additionally, it will be easier to add support for password and/or two factor based authentication. Functionality for this has been added to 1.x but the support for this will improve.
Better NextAuth Email
I'd like to include nice looking HTML email templates for sending emails and bundle nodemailer.
This behaviour should of course still be able to be overridden as it is now.
Bundle NextAuthClientI'd like to expose NextAuthClient directly in NextAuth (as NextAuth.Client) if this can be done simply and cleanly.It will provide a simpler way to use NextAuth and ensure both will be updated easily and were always in sync.NextAuth.Client is now already available in 1.x as it made sense to simplify how it was used and didn't require major changes client side.
The bundler for NextAuth.Client may change at some point, as there are some issues with newer webpack releases that mean it no longer generate isomorphic libraries that also run in service workers correctly (so for now we are not using the latest-and-greatest webpack to build it, as older versions work fine for universal apps) but even if we do that shouldn't change how it is used.
Rollup is one option and is much simpler, though it doesn't support Hot Module Replacement (HMR) and that might be a problem.
The text was updated successfully, but these errors were encountered: