-
Notifications
You must be signed in to change notification settings - Fork 86
Implement Google Oauth2 login + Account Linking #229
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #229 +/- ##
==========================================
- Coverage 30.36% 30.17% -0.20%
==========================================
Files 113 118 +5
Lines 8012 8126 +114
==========================================
+ Hits 2433 2452 +19
- Misses 5579 5674 +95 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
1e175b3 to
f206116
Compare
Closed
Signed-off-by: stadust <43299462+stadust@users.noreply.github.com>
Signed-off-by: stadust <43299462+stadust@users.noreply.github.com>
If these are wanted, they can be applied on the form-input itself, since all form inputs we are using are laid out top-to-bottom anyway. Signed-off-by: stadust <43299462+stadust@users.noreply.github.com>
Signed-off-by: stadust <43299462+stadust@users.noreply.github.com>
Sometimes we might want to use these outside of forms. Signed-off-by: stadust <43299462+stadust@users.noreply.github.com>
Both /login and /register place CSRF and access tokens in cookies. Deduplicate the code with a helper function (especially because later on, oauth will _also_ need to place the same cookies). Signed-off-by: stadust <43299462+stadust@users.noreply.github.com>
Also add a dummy request handler to the backend which for now always returns 403 UNAUTHORIZED. We use the javascript callback version (instead of redirect) of the google oauth flow so that it's easier to display potential error messages directly on the login page, as well as to avoid the form data payload that google would give us if we let it directly POST to our servers (going through javascript allows us to convert to JSON, which is easier to deal with). Signed-off-by: stadust <43299462+stadust@users.noreply.github.com>
Mark as UNIQUE to prevent any bugs/race conditions from allowing the same google account for multiple pointercrate accounts. Signed-off-by: stadust <43299462+stadust@users.noreply.github.com>
Introduce a new `AuthenticationType` for these, so that password based login will automatically be rejected. Signed-off-by: stadust <43299462+stadust@users.noreply.github.com>
Have the backend validate credentials it receives via /auth/oauth/google with the certificates that google publishes, decode the associated JWT to determine the google account id, and then log in the user who has that google account id linked by placing the required cookies. Signed-off-by: stadust <43299462+stadust@users.noreply.github.com>
Signed-off-by: stadust <43299462+stadust@users.noreply.github.com>
Signed-off-by: stadust <43299462+stadust@users.noreply.github.com>
When reaching the /oauth/google endpoint fully authenticated, and the provided google credentials are valid, link the authenticated pointercrate account with the google account. Only do so it the google account is not already linked to another pointercrate account, and if the pointercrate account is not already linked to a google account (e.g. re-linking from one google account to a different one is not possible right now). Signed-off-by: stadust <43299462+stadust@users.noreply.github.com>
Add an integration test to ensure that if a google account is linked to a pointercrate account, that pointercrate account becomes impossible to log in via username/password combo. Signed-off-by: stadust <43299462+stadust@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Allow linking google accounts to pointercrate accounts, to allow signing in through google. This then eliminates the option to sign in with pointercrate password, but also means you can no longer lock yourself out of your pointercrate account as easily (unless you also lock yourself out of your google account, but really, what are you doing?).
This is a very bare-bones implementation:
Essentially, we're implementing Phase 1 and 2 of #127, leaving Phase 3 and especially 4 for later work.
License Acceptance
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.