Closed Bug 1616596 Opened 4 years ago Closed 4 years ago

identity.launchWebAuthFlow sometimes is getting stuck while detecting the redirect_uri and then be resolved after a while

Categories

(WebExtensions :: Request Handling, defect, P1)

defect

Tracking

(firefox74+ wontfix, firefox75+ verified, firefox76+ verified)

VERIFIED FIXED
mozilla76
Tracking Status
firefox74 + wontfix
firefox75 + verified
firefox76 + verified

People

(Reporter: rpl, Assigned: rpl)

References

Details

Attachments

(2 files)

This issue seems similar to Bug 1528562, but the fix for Bug 1528562 doesn't cover this additional scenario yet (and the existing test case doesn't trigger it because it is using a POST but it is pointing it directly to the redirect_url, instead of receiving a POST reply and then navigating to the redirect_uri because of the Location header).

While trying to trigger the same issue I'm able to trigger while trying identity.launchWebAuthFlow on a local test oauth server (using https://github.com/14gasher/oauth-example to run a demo oauth server locally), I noticed that our test case should already be testing exactly the scenario described above (POST http request + redirect due to a Location header in the POST http reply) and I've not been yet able to figure out what is different between what happens in the test case (which pass successfully with and without my patch) and when I trigger the issue on the local oauth demo server (where identity.launchWebAuthFlow is getting stuck without my patch).

Assignee: nobody → lgreco
Status: NEW → ASSIGNED
Priority: -- → P2

Another really odd behavior of this issue (something that I noticed yesterday while trying to get more details when the issue is being triggered) is that a pretty long time (not just some seconds or milliseconds) the redirect is actually detected and the API call resolved with the expected url if I leave the auth dialog open.

Summary: identity.launchWebAuthFlow should detect the expected redirect_uri when received as a Location header in the reply to a POST request triggered by the OAuth2 webpage → identity.launchWebAuthFlow sometimes is getting stuck while detecting the redirect_uri and then be resolved after a while

I'm attaching some additional logs that I collected using MOZ_LOG="nsHttp:5".

At a first glance it seems that, while the identity.launchWebAuthFlow dialog is stuck, there is an "half open socket" pending for the redirect url and when the identity.launchWebAuthFlow gets finally resolved we have given up on the "half open socket" and the connection is being recreated in a way that finally trigger the onStateChange listener.

FWIW, we're seeing delays of up to 30 seconds with older versions of our extension as well as newly build ones on ff740.b9.
we hope ff74 is not going live until this one has been fixed, because it would expose our user base to those delays - something they certainly would blame us for.

(In reply to tom from comment #4)

FWIW, we're seeing delays of up to 30 seconds with older versions of our extension as well as newly build ones on ff740.b9.

Thank you for confirming that you can replicate Tom. Could you post steps to replicate here so others of us can test?

Flags: needinfo?(extensions)
Pushed by luca.greco@alcacoop.it:
https://hg.mozilla.org/integration/autoland/rev/cca1d61d1a7f
Use ChannelWrapper and nsIHttpActivityDistributor to detect when identity.launchWebAuthFlow dialog is being navigated to the redirect_uri. r=mixedpuppy
Flags: qe-verify+
Priority: P2 → P1

[Tracking Requested - why for this release]: This was identified on 74 too late, but it should be fixed if we get a dot release.

STR from reporter in comment 4, requires credentials provided via email:

With mailcheck 5.0:

steps to reproduce:

  1. turn off password management in preferences
  2. install xpi via addon debugging page
  3. click on browser action button
  4. type in user credentials; 1) submit email address, this triggers 2) the auth web flow;

after submitting the credentials; you should see a delay no longer than a second before you're done and email polling starts

Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla76

good job, thank you.

Flags: needinfo?(extensions)

Hello,

Verified the fix on the latest Nightly (76.0a1/20200310094445) under Windows 10 Pro 64-bit and MacOS Catalina 10.15.

After inputting the credentials as per the STR from Comment 8 and clicking the “Login” button, the authentication window closes immediately and email polling starts, confirming the fix.

Status: RESOLVED → VERIFIED

Comment on attachment 9129189 [details]
Bug 1616596 - Use ChannelWrapper and nsIHttpActivityDistributor to detect when identity.launchWebAuthFlow dialog is being navigated to the redirect_uri. r?mixedpuppy!

Beta/Release Uplift Approval Request

  • User impact if declined: Users may experience a considerably delay when an extension is using the identity.launchWebAuthFlow API method to retrieve the oauth token.

The delay may be quite long and the user may decide to close the oauth dialog before the authentication flow is completed (which would reject the API call and prevent the extension from working as expected).

  • Is this code covered by automated tests?: Yes
  • Has the fix been verified in Nightly?: Yes
  • Needs manual test from QE?: Yes
  • If yes, steps to reproduce: Yes, this should be verified explicitly by QA, because the change is covered by automated tests (which prevents regressing the existing behaviors) but this particular issue scenario is not yet covered by an automated test.

The STR to use are the same used to verify the fix on Nightly (See Bug 1616596 comment 8).

  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): The change is small enough and restricted to the part of the identity API implementation that detects when the oauth dialog is starting a navigation to the expected redirect_uri.

The API is covered by automated tests (which would prevent to regress the other expected behaviors), and the fix for this particular issue has been explicitly verified by QA (and from the developer of one of the affected extension) on Nightly.

  • String changes made/needed:
Attachment #9129189 - Flags: approval-mozilla-beta?

Comment on attachment 9129189 [details]
Bug 1616596 - Use ChannelWrapper and nsIHttpActivityDistributor to detect when identity.launchWebAuthFlow dialog is being navigated to the redirect_uri. r?mixedpuppy!

approved for 75.0b2

Attachment #9129189 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Regressions: 1594592
QA Whiteboard: [qa-triaged]

Hello,

Sorry I forgot to mention it yesterday, but I was able to consistently reproduce the issue at hand as per the provided STR on Beta 75.0b1 (75.0b1/20200309155231) and Release 74.0 (74.0/20200309095159) under Windows 10 Pro 64-bit and MacOS Catalina 10.15.

Furthermore, I have verified the fix on the latest Beta (75.0b2/20200310192828) under Windows 10 Pro 64-bit and MacOS Catalina 10.15. After inputting the credentials and clicking the “Login” button, the authentication window closes immediately and email polling starts, confirming the fix.

Flags: qe-verify+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: