Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Bug 1069412 - Email constantly asks me to reauthenticate #341

Merged
merged 2 commits into from Sep 27, 2014

Conversation

jrburke
Copy link
Contributor

@jrburke jrburke commented Sep 24, 2014

  • If an SMTP or IMAP connection fails due to a bad oauth token, allow for a forced renewal try of the access_token then try again.
  • To prevent aggressive retries, uses a_transientLastRenew timestamp, generated from date.PERFNOW, which uses performance.now when possible, to track if a renew was recently attempted.
  • Since performance.now can be reset or changed, we only know we will get a higher value within the lifetime of the window/worker, so js/composite/account.js resets the value on account instantiation. This is the part where I am not sure if this is the desired way to do this for GELAM, so appreciate there could be more idiomatic GELAM ways to do that.
  • I moved the credsUpdatedCallback work to be done inside oauth.js, instead of being being done by the callers in the client.js files, since the retry pathways would also need to do it.

// to give a buffer from a the token expiring before a renewal is
// attempted.
var expiresInMS = data.expires_in * 1000;
var expireTimeMS = Date.now() +
Copy link
Contributor

Choose a reason for hiding this comment

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

oi! date.NOW()!

@asutherland
Copy link
Contributor

This looks good but it needs new test coverage because things that could potentially infinitely loop scare me. The test should be pretty easy so I'm just going to do write one / modify an existing one now. I'll make the date.NOW change too. May alter the time warp slightly.

@asutherland
Copy link
Contributor

It turns out that the GELAM tests are a bit more work than I was expecting since we didn't actually ever create a full oauth-authed test. I'm still doing the test, but it's going to be a later-Thursday-afternoon thing since creating the fake oauth-server and the infrastructure to use it involves a medium amount of plumbing. I think this is the right call, still, though, especially since (after some more enhancement that only the front-end needs) we'll also be able to use this to integration-test the entire oauth flow in the front-end.

Most of the OAuth fake-server changes happened in mail-fakeservers on:
mozilla-b2g/mail-fakeservers#22
which I've speculatively landed and released as v0.0.28.  Further rev's
can be done as needed.
jrburke added a commit that referenced this pull request Sep 27, 2014
Bug 1069412 - Email constantly asks me to reauthenticate r=asuth
@jrburke jrburke merged commit 97acc38 into mozilla-b2g:master Sep 27, 2014
@jrburke jrburke deleted the bug1069412-email-xoauth2-reauth branch September 27, 2014 17:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants