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

🪟 🎉 Enable OAuth login #15414

Merged
merged 20 commits into from
Aug 17, 2022
Merged

🪟 🎉 Enable OAuth login #15414

merged 20 commits into from
Aug 17, 2022

Conversation

timroes
Copy link
Collaborator

@timroes timroes commented Aug 8, 2022

What

Closes https://github.com/airbytehq/airbyte-cloud/issues/1429

This implements OAuth login for our cloud application.

screenshot-20220808-164702

This does not require any backend changes, since Firebase gives us the same JWTs that already work on the backend. We have on frontend-dev a Google and GitHub dev application enabled, so this can fully tested against frontend-dev. Also LaunchDarkly currently has both login mechanism enabled on LaunchDarkly.

Some notes around behavior/function:

  • OAuth doesn't make a difference between login and sign up so the buttons on the login and signup page do exactly the same.
  • When logging in via Google to an existing account, this will work and log you into your existing account (since Google does know that your email is valid, and Firebase is a Google product). If you'd try to login using GitHub into an existing account with the same mail it will fail with a "auth/account-exists-with-different-credential" error code, which we show a warning for to log in using email/password.
  • You can perfectly fine request a new password for a mail that was originally logged into using OAuth, so no special handling needed there. If you will use the link you get via mail to set a new password it will convert the login from a GitHub account into a mail/password login (and after that you can't login using GitHub anymore, the same as mentioned above). In case of a Google account it will just be a "hybrid" account and you can login using either mail/password or sign in via google.
  • I've tried to comment everything in code as well as possible, also see my github comments for some implementation specific details.
  • The TOS checkbox was replaced by a pure disclaimer text below the login/signup buttons as discussion with Andy.
  • The invite user flow is still requiring users to register with a username/password afterwards. This is not an easy fix, since the way firebase handles invites via mail, the actual invite already is the login, and we just change the password. Addressing this will be postponed to a later PR (especially since users can always use Google to login later into the account they created this way).

@timroes timroes requested a review from a team as a code owner August 8, 2022 17:58
@timroes timroes added the area/frontend Related to the Airbyte webapp label Aug 8, 2022
@github-actions github-actions bot added the area/platform issues related to the platform label Aug 8, 2022
@timroes timroes added ui/auth and removed area/platform issues related to the platform labels Aug 8, 2022
} from "firebase/auth";

import { Provider } from "config";
import { FieldError } from "packages/cloud/lib/errors/FieldError";
import { EmailLinkErrorCodes, ErrorCodes } from "packages/cloud/services/auth/types";

interface AuthService {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ℹ️ We never exported this type, and implementing the interface in TypeScript does not even help not needing to respecify the types in the GoogleAuthService anyway. Thus this interface is not really fulfilling any purpose (besides needing to arbitrarily type the method signature twice) and I removed it.

interface AuthContextApi {
user: User | null;
inited: boolean;
emailVerified: boolean;
isLoading: boolean;
loggedOut: boolean;
login: AuthLogin;
loginWithOAuth: (provider: OAuthProviders) => Observable<OAuthLoginState>;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ℹ️ This method returns an Obersvable, since we need to know in the UI, when the middle of the method starts (the user selected an account, and we start loading the user), to show the loading spinner. Thus we can't express that with a Promise.

name: user.name,
email: user.email,
// Which login provider was used, e.g. "password", "google.com", "github.com"
provider: fbUser.providerData[0]?.providerId,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ℹ️ There is a chance a firebase user has multiple providers linked (e.g. mail and google as mentioned in the PR description). But that shouldn't be the case when the user is just created, in which case they should only have one provider linked, thus we can simply take the first provider here for sending the event.

@github-actions github-actions bot added the area/platform issues related to the platform label Aug 8, 2022
Copy link
Contributor

@edmundito edmundito left a comment

Choose a reason for hiding this comment

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

Initial feedback. I have not tested the changes locally.


&:hover,
&:focus {
box-shadow: 0 1px 3px rgba(53, 53, 66, 0.2), 0 1px 2px rgba(53, 53, 66, 0.12), 0 1px 1px rgba(53, 53, 66, 0.14);
Copy link
Contributor

Choose a reason for hiding this comment

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

Where did these drop shadow colors come from?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This shadow is from the regular button components. Most likely better to exctract it into a SASS variable. Any preference for which file?

Copy link
Contributor

Choose a reason for hiding this comment

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

airbyte-webapp/src/scss/_variables.scss seems the most appropriate, though a new file might be better. Not sure it's worth making a new file.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@edmundito Any preferences for a file we should pack this into?

@timroes timroes requested a review from edmundito August 10, 2022 13:25
@edmundito edmundito requested a review from a team August 10, 2022 13:39
@edmundito
Copy link
Contributor

@timroes looks like the most recent changes include removing the checkbox to agree to the TOS and the PP. Could you update the title/description of this PR?

@timroes
Copy link
Collaborator Author

timroes commented Aug 10, 2022

@timroes looks like the most recent changes include removing the checkbox to agree to the TOS and the PP. Could you update the title/description of this PR?

@edmundito updated it in the description!

@edmundito
Copy link
Contributor

Did some local testing and found a couple of issues:

The scroll needs to be fixed for smaller screen heights:
image

The "interested in self hosting" CTA seems too close to the sign up actions:
image

If I try to sign in with google, close the popup, and then try with github, I see an error when I shouldn't:
image

The sign up button should only be enabled if I filled out information, but it's enabled when I load the page:
image

Co-authored-by: Edmundo Ruiz Ghanem <168664+edmundito@users.noreply.github.com>
@timroes
Copy link
Collaborator Author

timroes commented Aug 10, 2022

The sign up button should only be enabled if I filled out information, but it's enabled when I load the page:

This is the prior and desired behavior at the moment (we'll later make this disabled by default, for users coming from GDPR affected countries).

The scroll needs to be fixed for smaller screen heights:

This issue is also on master, and since it might touch more code again (e.g. the scaling of the iframe might need to be addressed as well?) I'd prefer if we don't mix the fix into this PR.

The "interested in self hosting" CTA seems too close to the sign up actions:

This was also present beforehand, and it makes sense to change this whole page to use flexbox or grid. So same here: if possible I'd prefer moving that into a separate PR, if it would be okay for you?

@krishnaglick
Copy link
Contributor

This appears to be working as expected locally 👍

@timroes timroes changed the title 🪟 Enable OAuth login 🪟 🎉 Enable OAuth login Aug 15, 2022
@timroes
Copy link
Collaborator Author

timroes commented Aug 15, 2022

Created #15650 to track the scroll issues on the login/sign-up page.

@github-actions github-actions bot added the area/platform issues related to the platform label Aug 17, 2022
@timroes timroes merged commit 8c79e4f into master Aug 17, 2022
@timroes timroes deleted the tim/oauth branch August 17, 2022 13:15
rodireich pushed a commit that referenced this pull request Aug 25, 2022
* Enable OAuth login

* Style buttons

* Make sure to hide error wrapper without error

* Extract OAuthProviders type

* Make google login button outline more visible

* Add provider to segment identify call

* Switch TOS checkbox by disclaimer

* Address review feedback

* Hide password change section for OAuth accounts

* Update airbyte-webapp/src/packages/cloud/locales/en.json

Co-authored-by: Edmundo Ruiz Ghanem <168664+edmundito@users.noreply.github.com>

* Address review feedback

* Add additional flags to disable on sign-up

* Adding more tests

* Review feedback

* Fix broken linting

Co-authored-by: Edmundo Ruiz Ghanem <168664+edmundito@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/frontend Related to the Airbyte webapp area/platform issues related to the platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants