Commit Graph

2505 Commits

Author SHA1 Message Date
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
Iain Collins
2f61795697 Add verification of URL prefix cookie
Improves security and defence against bad actors by adding a hash that uses the secret as a salt and checking it on every request (and overriding the cookie with a new secure one if the check fails.)
2020-05-17 17:45:00 +01:00
Iain Collins
d5257fe1db Add signout page
This commit does not include handling of actual signout request.
2020-05-17 17:45:00 +01:00
Iain Collins
822fbee0c4 Fix bugs with server side session handling
* Sets site name + api route now prior to sign in so avalible sooner.
* Improved next-auth/client logic for server side session handling.
* next-auth/client now checks regular and `__Secure-` prefixed cookies.
2020-05-17 17:45:00 +01:00
Iain Collins
937f9cdfda Fix case sensitivy of prefix for secure cookies 2020-05-17 17:45:00 +01:00
Iain Collins
2bb9355933 Improve signin page
* Better contrast
* Displays site name correctly
2020-05-17 17:45:00 +01:00
Iain Collins
57a9021107 Add route to return CSRF token to clients 2020-05-17 17:45:00 +01:00
Iain Collins
71fecfb1f2 Standardize done() call for routes 2020-05-17 17:45:00 +01:00
Iain Collins
1b374817f0 Improve and standardize how responses are returned
Use .status() and .json() where possible.
2020-05-17 17:45:00 +01:00
Iain Collins
eee927a6cd Add CSRF token and improve cookie security
Better default security for cookies, without impacting UX or DX.

Further work to do on CSRF protection, but this is a good start.
2020-05-17 17:45:00 +01:00
Iain Collins
0fabfa4ef9 Add viewport metatag to pages for mobile devices 2020-05-17 17:45:00 +01:00
Iain Collins
57bf54c28d Fix useEffect() warning in client
Technically useEffect should not return a value, or generates a warning.
2020-05-17 17:45:00 +01:00
Iain Collins
9bbc9100ab Update documentation 2020-05-17 17:45:00 +01:00
Iain Collins
e6cd78d71b Bump version number to publish new README 2020-05-17 17:45:00 +01:00
Iain Collins
3d66b90cf8 Update README.md 2020-05-17 17:45:00 +01:00
Iain Collins
ebfb02bd12 Bump version number to update docs 2020-05-17 17:45:00 +01:00
Iain Collins
2032ff1276 Update README 2020-05-17 17:45:00 +01:00
Iain Collins
08582aad83 Fix bugs with parsing options
Some of the logic was wrong following refactoring.
2020-05-17 17:45:00 +01:00
Iain Collins
c9944820c6 Fix bug in client session method
Introduced when refactoring error handling
2020-05-17 17:45:00 +01:00
Iain Collins
0697609dd0 Add beta tag to version
While it is still somewhere between an alpha and a beta am publishing to NPM to facilitate further testing.

The software is not ready for use yet!

While belived to be functional there are no formal tests and only casual manual testing has been done.

Features such as logout and session expiry checks have not yet been implemented.
2020-05-17 17:45:00 +01:00
Iain Collins
39d3689c22 Improve client error handling 2020-05-17 17:45:00 +01:00
Iain Collins
43023293ea Remove install script
No longer needed.
2020-05-17 17:45:00 +01:00