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

fix(oauth-desktop): Call fxaLogin before fxaOAuthLogin with expected data during signin #17744

Merged
merged 1 commit into from
Oct 2, 2024

Conversation

LZoog
Copy link
Contributor

@LZoog LZoog commented Oct 1, 2024

Because:

  • We want to support the new oauth desktop flow, and there is a bug during signin because we were sending fxaOAuthLogin first

This commit:

  • Refactors signin/utils to swap the order these web channel messages fire
  • Fixes an additional intermittent bug for 2FA and new account signins caused by sending keyFetchToken and unwrapBKey
  • Adds oauth desktop config
  • Renames oauthCode to oauthData in oauth hook

fixes FXA-10388


Most of this was already accounted for in page-level tests. I'm going to be taking a better look at our test coverage in FXA-10328 next.

Test this by running yarn firefox for our desktop v3 flow and FXA_DESKTOP_CONTEXT=oauth_webchannel_v1 yarn firefox for the oauth desktop flow. Check out a standard Sync signin (requires email code), a new Sync account signin (no code), and 2FA signin. Users should be fully logged into Sync.

@LZoog LZoog requested a review from a team as a code owner October 1, 2024 22:29
@LZoog LZoog force-pushed the FXA-10388 branch 3 times, most recently from a3e7068 to ee4c67e Compare October 2, 2024 16:52
Copy link
Contributor

@jonalmeida jonalmeida left a comment

Choose a reason for hiding this comment

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

lgtm with mostly optional nits or questions.

I am a bit curious about the future maintainability of some of the logic here and how we could keep that testable as future frontend changes happen. These are just thoughts out loud though. 🙂

@@ -295,7 +295,7 @@
"id": "5882386c6d801776",
"hashedSecret": "71b5283536f1f1c331eca2f75c58a5947d7a7ac54164eadb4b33a889afe89fbf",
"imageUri": "",
"redirectUri": "urn:ietf:wg:oauth:2.0:oob:oauth-redirect-webchannel",
"redirectUri": "urn:ietf:wg:oauth:2.0:oob:oauth-redirect-webchannel,http://localhost:3030/oauth/success/5882386c6d801776",
Copy link
Contributor

Choose a reason for hiding this comment

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

Non-blocking question: Just want to verify if it intentional to also include this localhost as well even though this is the dev.json since we've had oauth desktop supported before and we hadn't needed this then.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting, I'll cc @vbudhram on this one. Tarik had previously shared this diff with us to test oauth desktop, and I've manually been using this any time I've needed to test for it, and had problems with it not working without this (500 errors locally).

packages/fxa-dev-launcher/README.md Show resolved Hide resolved
packages/fxa-dev-launcher/profile.mjs Show resolved Hide resolved
Comment on lines +301 to +304
// NOTE, Oauth desktop needs to add `service=sync` as a query parameter for this
// to take users to the inline recovery key flow (SYNC-4408). (We may want
// check for client ID to determine oauth desktop instead, TBD slight refactor for
// FXA-10313).
Copy link
Contributor

Choose a reason for hiding this comment

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

For my own sanity: we had checked the source offline for app services and saw that service=sync is not used there for consumers of the oauth fxaclient (currently only our mobile browsers). However, I forgot to check desktop separately as well, which has a bunch of tests for fx_desktop_v3 which still exist: https://searchfox.org/mozilla-central/search?q=service%3Dsync&path=&case=false&regexp=false

packages/fxa-settings/src/pages/Signin/mocks.tsx Outdated Show resolved Hide resolved
packages/fxa-settings/src/pages/Signin/utils.ts Outdated Show resolved Hide resolved
…data during signin

Because:
* We want to support the new oauth desktop flow, and there is a bug during signin because we were sending fxaOAuthLogin first

This commit:
* Refactors signin/utils to swap the order these web channel messages fire
* Fixes an additional intermittent bug for 2FA and new account signins caused by sending keyFetchToken and unwrapBKey
* Adds oauth desktop config
* Renames oauthCode to oauthData in oauth hook

fixes FXA-10388
@LZoog LZoog merged commit d674ef2 into main Oct 2, 2024
26 checks passed
@LZoog LZoog deleted the FXA-10388 branch October 2, 2024 23:46
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.

2 participants