Bug 1059391 - Add pref to disable caching of Sync authentication credentials. r=markh

This introduces a debugging pref, "services.sync.debug.ignoreCachedAuthCredentials".
This flag allows testers to disable caching of authentication credentials
to make debugging of expired and revoked credentials easier. This will
help expedite any visble auth errors resulting from a expired or revoked
FxA session token, e.g., from resetting or changing the FxA password.
This pref is not set by default.
This commit is contained in:
Chris Karlof 2014-08-28 17:21:03 -07:00
parent 62f7c5af6c
commit 4faeb7fc5a
2 changed files with 23 additions and 1 deletions

View File

@ -163,7 +163,18 @@ AccountState.prototype = {
}, },
getKeyPair: function(mustBeValidUntil) { getKeyPair: function(mustBeValidUntil) {
if (this.keyPair && (this.keyPair.validUntil > mustBeValidUntil)) { // If the debugging pref to ignore cached authentication credentials is set for Sync,
// then don't use any cached key pair, i.e., generate a new one and get it signed.
// The purpose of this pref is to expedite any auth errors as the result of a
// expired or revoked FxA session token, e.g., from resetting or changing the FxA
// password.
let ignoreCachedAuthCredentials = false;
try {
ignoreCachedAuthCredentials = Services.prefs.getBoolPref("services.sync.debug.ignoreCachedAuthCredentials");
} catch(e) {
// Pref doesn't exist
}
if (!ignoreCachedAuthCredentials && this.keyPair && (this.keyPair.validUntil > mustBeValidUntil)) {
log.debug("getKeyPair: already have a keyPair"); log.debug("getKeyPair: already have a keyPair");
return this.resolve(this.keyPair.keyPair); return this.resolve(this.keyPair.keyPair);
} }

View File

@ -475,6 +475,17 @@ this.BrowserIDManager.prototype = {
* signed in? * signed in?
*/ */
hasValidToken: function() { hasValidToken: function() {
// If pref is set to ignore cached authentication credentials for debugging,
// then return false to force the fetching of a new token.
let ignoreCachedAuthCredentials = false;
try {
ignoreCachedAuthCredentials = Svc.Prefs.get("debug.ignoreCachedAuthCredentials");
} catch(e) {
// Pref doesn't exist
}
if (ignoreCachedAuthCredentials) {
return false;
}
if (!this._token) { if (!this._token) {
return false; return false;
} }