Commit Graph

2126 Commits

Author SHA1 Message Date
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
Iain Collins
c62617532f Improve email sign in (email, error, options) 2020-05-17 17:45:00 +01:00
Iain Collins
fc28374f88 Add email sign in flow
* Added email verification adapater methods
* Added support on sign in page for email providers
* Added check email page
* Added SMTP transport to send email messages

Includes refactoring of model and handlers for the email verification flow.
2020-05-17 17:45:00 +01:00
Iain Collins
6ec9d8e9d0 Rename deleteUserById to and getUserById
Brings them into line with other methods.

Not refactoring other getUser* methods at this time as may be helpful for them to be explicit about what will be passed.
2020-05-17 17:45:00 +01:00
Iain Collins
26d41d4a2b Refactor session API in adapter
* Renamed 'Session ID' to 'Session Token'.
* Applies to model, functions and default cookie name.
* This avoids confusion by seperating it from 'id' property in session model.
2020-05-17 17:45:00 +01:00
Iain Collins
b6c2befba7 Add verification request methods to adapter 2020-05-17 17:45:00 +01:00
Iain Collins
0d96a7e9e5 Rename Invite model to Verify 2020-05-17 17:45:00 +01:00
Iain Collins
3006161bce Documentation and linting updates
* Updated documentation
* `lint` and `lint:fix` now seperate scripts
* Fixed simple linting issues

Still some linter errors as the email sign up flow is a work in progress.
2020-05-17 17:45:00 +01:00
Lori Karikari
c653a1cc72 Added Mixer, Discord, Slack and Reddit (partially) (#111)
* added a temporary? state param
* added Discord, Mixer, Slack and partial Reddit providers

Co-authored-by: Iain Collins <me@iaincollins.com>
2020-05-17 17:45:00 +01:00
Iain Collins
301f048ce3 Signup bug fixes and enhancements
* Improve CSRF token verification
* Improved access token generation
* Added work in progress code for email signin provider
2020-05-17 17:45:00 +01:00
Iain Collins
3ac6666bee Additional debugging in oAuth callback
Logs provider name and code / token when access token request fails.
2020-05-17 17:45:00 +01:00
Iain Collins
73a5be5d6c Fix for breaking changes in Twitch API
Twitch recently made breaking changes to their oAuth API.

It no longer works like other oAuth 2 providers. The documentation for it is extensive, but poor quality.

This update still has intermittant problems, but as far as I can make out  the problem is the API; they have completed their roll out to 100% but it's still failing sometimes.
2020-05-17 17:45:00 +01:00
Iain Collins
ed6328679a Improve client
* Improve options passing
* Fix bug with cookie parsing
* Remove isomorphic-unfetch (fetch built from Next.js 9.4)
2020-05-17 17:45:00 +01:00
Iain Collins
8eb9c4822e Bump version to beta 16 2020-05-17 17:45:00 +01:00
Iain Collins
8a9e2305c8 Fix typo in comment 2020-05-17 17:45:00 +01:00
Iain Collins
7ef2a2ec93 Add eslint with Standard JS and reformat code
* Run `npm run lint` to find (and where possible, fix) linting issues.
* Includes some minor refactoring, including directory structure for adapters and models, so that code for an adapter and the models for it sit together.

Background:

I've added elint to try and ensure a consistent style and to uncover hidden bugs.

I don't actually care much about what the rules are, it's just helpful to have a baseline.

If it's hard to get code to be compliant, I would rather we just disable a rule in that block of code until we can figure it out and am totally fine with that.

I'd much prefer that than the chore of maintaining a custom set of rules, which is why I just picked Standard JS.

Unfortunately, there is quite a lot that doesn't match the Standard JS format at this point, so this is going to be a big PR.

The file size has gone down in quite a few places, which is nice. I think it may have uncovered potential bugs.

I've run through the flow and everything seems to work as before, though it took some debugging after refactoring.

I have not yet added eslint to a commit hook and am in two minds about that.

This is an open source project and I'd like to make it easy to maintain, but also to have as low a barrier to entry as possible for contributors.

I'm happy to go with encouraging folks to run the linter and try to fix errors they find and to take on the work of wrangling any issues myself.
2020-05-17 17:45:00 +01:00
Fredrik Pettersen
67d49fe483 refactor: Combine useSession and useGlobalSession into one hook 2020-05-17 17:45:00 +01:00
Fredrik Pettersen
cc2753efd5 feat(client): Add useGlobalSession which uses react context 2020-05-17 17:45:00 +01:00
Iain Collins
d0a403e56a Improve auth page CSS 2020-05-17 17:45:00 +01:00
Iain Collins
ab9d1d0a91 Add log and error page to handle signup errors
This error page will be used to handle display all errors to the client.

There will be an option to provide a custom error page URL.

Update includes some tweaks to CSS.
2020-05-17 17:45:00 +01:00
Iain Collins
c85ad74508 Fix bug with session expiry date
* Should database compatability issues with the model.
* Session expiry dates are still not enforced in client.
* All cookies are still sesison cookies and expire when the browser is closed.
* AccessToken expiry has been removed for now.

These are all know issues and intended behaviour for now, and will be addressed before release.
2020-05-17 17:45:00 +01:00
Iain Collins
2dca9308e9 Delete .DS_Store
<<< .DS_Store rage intensifies >>>
2020-05-17 17:45:00 +01:00
Iain Collins
494a267527 Fix typo import twitch provider
This worked locally as local file system is not case sensitive.
2020-05-17 17:45:00 +01:00
Iain Collins
4c163d54ca Fix bug with callback URL triggered on signout
In some flows the signout values was returning 'undefined'.
2020-05-17 17:45:00 +01:00
Iain Collins
b9853b362b Export Twitch provider
I haven't had a chance to test it myself yet, but very happy to include it!
2020-05-17 17:45:00 +01:00
Lori
121e978d76 added Twitch provider 2020-05-17 17:45:00 +01:00
Iain Collins
b9142217a9 Refactor callback URL handler
Less code in one place and less code overall.
2020-05-17 17:45:00 +01:00
Iain Collins
74d67dd801 Refactor callback URL handling
* Logic now centralized to avoid duplicaiton across multiple routes.
* Improved validation of query params.
* Also checks and cookie values as mitigation against cookie hijacking.
2020-05-17 17:45:00 +01:00
Iain Collins
121ed4a58e Add deleteSessionById() so signing out works
Can now securely sign out. Session cookie and entry in session db are deleted.
2020-05-17 17:45:00 +01:00
Iain Collins
cf903ca82e Add route to handle signout POST
* CSRF token is verified first.
* If token doesn't match, redirect client to signout URL to prompt for confirmation.
* `deleteSessionById()` not yet implemented in default adapter, so does not work.
* Identified area for reafactoring around callbackUrl behaviour.
2020-05-17 17:45:00 +01:00