Skip to content

Commit

Permalink
Force Account Consistency off for Logout call on iOS.
Browse files Browse the repository at this point in the history
The GaiaAuthFetcher Logout call needs Account Consistency to be
disabled to work properly. On iOS, the state of Account Consistency is
handled by cookies set on the various Google domains. Sadly, the cookie
clearing request is not synchronized with the Logout call and there is
a race between the two.

This CL forces the cookie to be invalid during the Logout request to
ensure the accounts will be cleared. The cookie will eventually be
invalidated in the WKWebView cookie jar when AccountConsistencyService
finishes.

BUG=569501

Review URL: https://codereview.chromium.org/1522873002

Cr-Commit-Position: refs/heads/master@{#365248}
  • Loading branch information
bzanotti authored and Commit bot committed Dec 15, 2015
1 parent 3706ec0 commit def2982
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
6 changes: 5 additions & 1 deletion google_apis/gaia/gaia_auth_fetcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@ void GaiaAuthFetcher::SetPendingFetch(bool pending_fetch) {
fetch_pending_ = pending_fetch;
}

void GaiaAuthFetcher::SetLogoutHeaders(const std::string& headers) {
logout_headers_ = headers;
}

void GaiaAuthFetcher::CancelRequest() {
fetcher_.reset();
fetch_pending_ = false;
Expand Down Expand Up @@ -629,7 +633,7 @@ void GaiaAuthFetcher::StartListAccounts() {
void GaiaAuthFetcher::StartLogOut() {
DCHECK(!fetch_pending_) << "Tried to fetch two things at once!";

CreateAndStartGaiaFetcher(std::string(), std::string(), logout_gurl_,
CreateAndStartGaiaFetcher(std::string(), logout_headers_, logout_gurl_,
net::LOAD_NORMAL);
}

Expand Down
6 changes: 6 additions & 0 deletions google_apis/gaia/gaia_auth_fetcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@ class GaiaAuthFetcher : public net::URLFetcherDelegate {

void SetPendingFetch(bool pending_fetch);

// Set the headers to use during the Logout call.
void SetLogoutHeaders(const std::string& headers);

private:
// The format of the POST body for IssueAuthToken.
static const char kIssueAuthTokenFormat[];
Expand Down Expand Up @@ -430,6 +433,9 @@ class GaiaAuthFetcher : public net::URLFetcherDelegate {
std::string requested_service_;
bool fetch_pending_;

// Headers used during the Logout call.
std::string logout_headers_;

friend class GaiaAuthFetcherTest;
FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, CaptchaParse);
FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, AccountDeletedError);
Expand Down
7 changes: 6 additions & 1 deletion ios/chrome/browser/signin/gaia_auth_fetcher_ios.mm
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,12 @@ - (void)webView:(WKWebView*)webView
web::BrowserState* browser_state)
: GaiaAuthFetcher(consumer, source, getter),
bridge_(new GaiaAuthFetcherIOSBridge(this, browser_state)),
browser_state_(browser_state) {}
browser_state_(browser_state) {
// Account Consistency needs to be disabled for the Logout call. There is a
// race with the cookie clearing request (handled by
// AccountConsistencyService), so we invalidate the cookie for the call.
SetLogoutHeaders("Cookie: X-CHROME-CONNECTED=EXPIRED;");
}

GaiaAuthFetcherIOS::~GaiaAuthFetcherIOS() {
}
Expand Down

0 comments on commit def2982

Please sign in to comment.