Skip to content
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

integrate google oauth #50

Merged
merged 25 commits into from
Apr 28, 2019
Merged

integrate google oauth #50

merged 25 commits into from
Apr 28, 2019

Conversation

jeredw
Copy link
Contributor

@jeredw jeredw commented Apr 27, 2019

Integrates google oauth into captain registration, login, and invite flows.

Views can now link users to /google/login with session['oauth_next_url'] set to a
callback url. After authentication, google will redirect to /google/auth, which will
redirect to session['oauth_next_url'] with session['oauth_user_info'] filled with user
data. This allows us to modify existing view logic to grab data from the session
store instead of from form fields.

The use of global session store isn't ideal, but there doesn't seem to be a better
way. As a precaution, oauth session keys should always be popped by consuming
views, and are cleared for non-consuming views by an @app.before_request
handler.

This patchset also includes some UI changes to make the sign in button fit in more
sensibly with the existing UI, and a few fixes for minor bugs in the enlist flow.

Fixes #1

@jeredw jeredw requested a review from igor47 April 27, 2019 20:40
Copy link
Member

@igor47 igor47 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks great! i left a few pieces of feedback, and also identified a few opportunities for refactoring. we need to start pulling some code out of our controllers.

@@ -13,3 +13,6 @@ class Config:
MYSQL_USERNAME = os.environ.get('MYSQL_USERNAME', 'spaceship-app')
MYSQL_PASSWORD = os.environ.get('MYSQL_PASSWORD', 'aa7925b6f7b')
MYSQL_DB = os.environ.get('MYSQL_DB', 'spaceship')

GOOGLE_CLIENT_ID = os.environ.get('GOOGLE_CLIENT_ID', '700492634886-qbhv3gss1a59lm5p93gr7plo872auaba.apps.googleusercontent.com')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should probably treat this cred the same as the sendgrid key, where if you want google oauth to work locally you can pull the secret off the k8s cluster. i can work on that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack, i'll merge this first, since it seems harmless and least likely to mess up others' workflows for now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tracked in issue #53

spaceship/views.py Outdated Show resolved Hide resolved
spaceship/views.py Outdated Show resolved Hide resolved
spaceship/views.py Outdated Show resolved Hide resolved
spaceship/views.py Outdated Show resolved Hide resolved
password = register.data['password']

if name and email_address:
with db.atomic() as transaction:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mmm, we have a bit of copy-pasta. i think our views are starting to get a little heavy, i'd like to refactor some of this code into service objects or some equivalent way to encapsulate business logic (since service objects seem very RoR-oriented)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hrm, yeah, we could just move related sets of db mutation and queries out into functions in logically named files. i'll take a look at this after some ui tweaks and other stuff for mvp is in.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tracked in issue #52

jeredw added 2 commits April 27, 2019 17:06
* 'oauth' of github.com:spaceshipearth/pyspaceship:
  k8s: add a port variable to mysql config
  db: use a connection pool
  views: add a logger
  explicitly open and close connections for each request
  use mission title to link to mission research details
@jeredw
Copy link
Contributor Author

jeredw commented Apr 28, 2019

thanks for reviewing, I addressed some comments in a followup patch and left open one discussion about refactoring.

@jeredw jeredw closed this Apr 28, 2019
@jeredw
Copy link
Contributor Author

jeredw commented Apr 28, 2019

oops didn't mean to close, apparently

@jeredw jeredw reopened this Apr 28, 2019
@jeredw jeredw merged commit 5f204e5 into master Apr 28, 2019
@jeredw jeredw deleted the oauth branch April 28, 2019 00:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

log in via google oauth
2 participants