From ddbeda388dae931edb9a645c67edadb176591501 Mon Sep 17 00:00:00 2001 From: Alexander Alekseev Date: Tue, 21 Nov 2017 10:36:09 +0000 Subject: [PATCH] Revert "Implement the calls to GAIA for the IDP IFrame protocol." Remove unused code in gaia_apis. This reverts commit efc601eba6eb6b7efdaa38d2c49b7d3665e7f9c7. It was reviewed here: https://codereview.chromium.org/973953002. Bug: 787260 Change-Id: If8ee0b6b03c8940d81589ceeb5703f39c32aafde Reviewed-on: https://chromium-review.googlesource.com/780377 Reviewed-by: Mihai Sardarescu Commit-Queue: Alexander Alekseev Cr-Commit-Position: refs/heads/master@{#518206} --- google_apis/gaia/gaia_auth_consumer.h | 6 - google_apis/gaia/gaia_auth_fetcher.cc | 137 +----------------- google_apis/gaia/gaia_auth_fetcher.h | 22 +-- .../gaia/gaia_auth_fetcher_unittest.cc | 3 - google_apis/gaia/gaia_urls.cc | 7 - google_apis/gaia/gaia_urls.h | 2 - 6 files changed, 5 insertions(+), 172 deletions(-) diff --git a/google_apis/gaia/gaia_auth_consumer.h b/google_apis/gaia/gaia_auth_consumer.h index 3b87d01019c5be..ccaf81a5092aee 100644 --- a/google_apis/gaia/gaia_auth_consumer.h +++ b/google_apis/gaia/gaia_auth_consumer.h @@ -94,12 +94,6 @@ class GaiaAuthConsumer { virtual void OnGetCheckConnectionInfoSuccess(const std::string& data) {} virtual void OnGetCheckConnectionInfoError( const GoogleServiceAuthError& error) {} - - virtual void OnListIdpSessionsSuccess(const std::string& login_hint) {} - virtual void OnListIdpSessionsError(const GoogleServiceAuthError& error) {} - - virtual void OnGetTokenResponseSuccess(const ClientOAuthResult& result) {} - virtual void OnGetTokenResponseError(const GoogleServiceAuthError& error) {} }; #endif // GOOGLE_APIS_GAIA_GAIA_AUTH_CONSUMER_H_ diff --git a/google_apis/gaia/gaia_auth_fetcher.cc b/google_apis/gaia/gaia_auth_fetcher.cc index 5816ed27e78f72..578bf722941a88 100644 --- a/google_apis/gaia/gaia_auth_fetcher.cc +++ b/google_apis/gaia/gaia_auth_fetcher.cc @@ -45,13 +45,11 @@ static bool CookiePartsContains(const std::vector& parts, return false; } -// From the JSON string |data|, extract the |access_token| and |expires_in_secs| -// both of which must exist. If the |refresh_token| is non-NULL, then it also -// must exist and is extraced; if it's NULL, then no extraction is attempted. bool ExtractOAuth2TokenPairResponse(const std::string& data, std::string* refresh_token, std::string* access_token, int* expires_in_secs) { + DCHECK(refresh_token); DCHECK(access_token); DCHECK(expires_in_secs); @@ -62,16 +60,12 @@ bool ExtractOAuth2TokenPairResponse(const std::string& data, base::DictionaryValue* dict = static_cast(value.get()); - if (!dict->GetStringWithoutPathExpansion("access_token", access_token) || + if (!dict->GetStringWithoutPathExpansion("refresh_token", refresh_token) || + !dict->GetStringWithoutPathExpansion("access_token", access_token) || !dict->GetIntegerWithoutPathExpansion("expires_in", expires_in_secs)) { return false; } - // Refresh token may not be required. - if (refresh_token) { - if (!dict->GetStringWithoutPathExpansion("refresh_token", refresh_token)) - return false; - } return true; } @@ -88,9 +82,6 @@ void GetCookiesFromResponse(const net::HttpResponseHeaders* headers, } } -const char kListIdpServiceRequested[] = "list_idp"; -const char kGetTokenResponseRequested[] = "get_token"; - } // namespace // static @@ -196,7 +187,6 @@ GaiaAuthFetcher::GaiaAuthFetcher(GaiaAuthConsumer* consumer, logout_gurl_(GaiaUrls::GetInstance()->LogOutURLWithSource(source)), get_check_connection_info_url_( GaiaUrls::GetInstance()->GetCheckConnectionInfoURLWithSource(source)), - oauth2_iframe_url_(GaiaUrls::GetInstance()->oauth2_iframe_url()), deprecated_client_login_to_oauth2_gurl_( GaiaUrls::GetInstance()->deprecated_client_login_to_oauth2_url()) {} @@ -376,43 +366,6 @@ std::string GaiaAuthFetcher::MakeOAuthLoginBody(const std::string& service, encoded_source.c_str()); } -// static -std::string GaiaAuthFetcher::MakeListIDPSessionsBody( - const std::string& scopes, - const std::string& domain) { - static const char getTokenResponseBodyFormat[] = - "action=listSessions&" - "client_id=%s&" - "origin=%s&" - "scope=%s"; - std::string encoded_client_id = net::EscapeUrlEncodedData( - GaiaUrls::GetInstance()->oauth2_chrome_client_id(), true); - return base::StringPrintf(getTokenResponseBodyFormat, - encoded_client_id.c_str(), - domain.c_str(), - scopes.c_str()); -} - -std::string GaiaAuthFetcher::MakeGetTokenResponseBody( - const std::string& scopes, - const std::string& domain, - const std::string& login_hint) { - static const char getTokenResponseBodyFormat[] = - "action=issueToken&" - "client_id=%s&" - "login_hint=%s&" - "origin=%s&" - "response_type=token&" - "scope=%s"; - std::string encoded_client_id = net::EscapeUrlEncodedData( - GaiaUrls::GetInstance()->oauth2_chrome_client_id(), true); - return base::StringPrintf(getTokenResponseBodyFormat, - encoded_client_id.c_str(), - login_hint.c_str(), - domain.c_str(), - scopes.c_str()); -} - // static void GaiaAuthFetcher::ParseClientLoginFailure(const std::string& data, std::string* error, @@ -476,40 +429,6 @@ bool GaiaAuthFetcher::ParseClientLoginToOAuth2Cookie(const std::string& cookie, return false; } -// static -bool GaiaAuthFetcher::ParseListIdpSessionsResponse(const std::string& data, - std::string* login_hint) { - DCHECK(login_hint); - - std::unique_ptr value = base::JSONReader::Read(data); - if (!value.get() || value->type() != base::Value::Type::DICTIONARY) - return false; - - base::DictionaryValue* dict = - static_cast(value.get()); - - base::ListValue* sessionsList; - if (!dict->GetList("sessions", &sessionsList)) - return false; - - // Find the first login_hint present in any session. - for (base::ListValue::iterator iter = sessionsList->begin(); - iter != sessionsList->end(); - iter++) { - base::DictionaryValue* sessionDictionary; - if (!iter->GetAsDictionary(&sessionDictionary)) - continue; - - if (sessionDictionary->GetString("login_hint", login_hint)) - break; - } - - if (login_hint->empty()) - return false; - return true; -} - - void GaiaAuthFetcher::StartRevokeOAuth2Token(const std::string& auth_token) { DCHECK(!fetch_pending_) << "Tried to fetch two things at once!"; @@ -936,7 +855,6 @@ void GaiaAuthFetcher::StartGetCheckConnectionInfo() { kLoadFlagsIgnoreCookies, traffic_annotation); } - // static GoogleServiceAuthError GaiaAuthFetcher::GenerateAuthError( const std::string& data, @@ -1139,48 +1057,6 @@ void GaiaAuthFetcher::OnGetCheckConnectionInfoFetched( } } -void GaiaAuthFetcher::OnListIdpSessionsFetched( - const std::string& data, - const net::URLRequestStatus& status, - int response_code) { - if (status.is_success() && response_code == net::HTTP_OK) { - VLOG(1) << "ListIdpSessions successful!"; - std::string login_hint; - if (ParseListIdpSessionsResponse(data, &login_hint)) { - consumer_->OnListIdpSessionsSuccess(login_hint); - } else { - GoogleServiceAuthError auth_error( - GoogleServiceAuthError::FromUnexpectedServiceResponse( - "List Sessions response didn't contain a login_hint.")); - consumer_->OnListIdpSessionsError(auth_error); - } - } else { - consumer_->OnListIdpSessionsError(GenerateAuthError(data, status)); - } -} - -void GaiaAuthFetcher::OnGetTokenResponseFetched( - const std::string& data, - const net::URLRequestStatus& status, - int response_code) { - std::string access_token; - int expires_in_secs = 0; - bool success = false; - if (status.is_success() && response_code == net::HTTP_OK) { - VLOG(1) << "GetTokenResponse successful!"; - success = ExtractOAuth2TokenPairResponse(data, NULL, - &access_token, &expires_in_secs); - } - - if (success) { - consumer_->OnGetTokenResponseSuccess( - GaiaAuthConsumer::ClientOAuthResult(std::string(), access_token, - expires_in_secs)); - } else { - consumer_->OnGetTokenResponseError(GenerateAuthError(data, status)); - } -} - void GaiaAuthFetcher::OnURLFetchComplete(const net::URLFetcher* source) { fetch_pending_ = false; // Some of the GAIA requests perform redirects, which results in the final @@ -1240,13 +1116,6 @@ void GaiaAuthFetcher::DispatchFetchedRequest( OnLogOutFetched(data, status, response_code); } else if (url == get_check_connection_info_url_) { OnGetCheckConnectionInfoFetched(data, status, response_code); - } else if (url == oauth2_iframe_url_) { - if (requested_service_ == kListIdpServiceRequested) - OnListIdpSessionsFetched(data, status, response_code); - else if (requested_service_ == kGetTokenResponseRequested) - OnGetTokenResponseFetched(data, status, response_code); - else - NOTREACHED(); } else { NOTREACHED(); } diff --git a/google_apis/gaia/gaia_auth_fetcher.h b/google_apis/gaia/gaia_auth_fetcher.h index 097267ebee4039..0c4ae11c3f8611 100644 --- a/google_apis/gaia/gaia_auth_fetcher.h +++ b/google_apis/gaia/gaia_auth_fetcher.h @@ -334,14 +334,6 @@ class GaiaAuthFetcher : public net::URLFetcherDelegate { const net::URLRequestStatus& status, int response_code); - void OnListIdpSessionsFetched(const std::string& data, - const net::URLRequestStatus& status, - int response_code); - - void OnGetTokenResponseFetched(const std::string& data, - const net::URLRequestStatus& status, - int response_code); - // Tokenize the results of a ClientLogin fetch. static void ParseClientLoginResponse(const std::string& data, std::string* sid, @@ -362,9 +354,6 @@ class GaiaAuthFetcher : public net::URLFetcherDelegate { static bool ParseClientLoginToOAuth2Cookie(const std::string& cookie, std::string* auth_code); - static bool ParseListIdpSessionsResponse(const std::string& data, - std::string* login_hint); - // Is this a special case Gaia error for TwoFactor auth? static bool IsSecondFactorSuccess(const std::string& alleged_error); @@ -398,13 +387,6 @@ class GaiaAuthFetcher : public net::URLFetcherDelegate { static std::string MakeOAuthLoginBody(const std::string& service, const std::string& source); - static std::string MakeListIDPSessionsBody(const std::string& scopes, - const std::string& domain); - - static std::string MakeGetTokenResponseBody(const std::string& scopes, - const std::string& domain, - const std::string& login_hint); - // From a URLFetcher result, generate an appropriate error. // From the API documentation, both IssueAuthToken and ClientLogin have // the same error returns. @@ -426,13 +408,13 @@ class GaiaAuthFetcher : public net::URLFetcherDelegate { const GURL list_accounts_gurl_; const GURL logout_gurl_; const GURL get_check_connection_info_url_; - const GURL oauth2_iframe_url_; // While a fetch is going on: std::unique_ptr fetcher_; GURL deprecated_client_login_to_oauth2_gurl_; std::string request_body_; - std::string requested_service_; + + std::string requested_service_; // Currently tracked for IssueAuthToken only. bool fetch_pending_ = false; bool fetch_token_from_auth_code_ = false; diff --git a/google_apis/gaia/gaia_auth_fetcher_unittest.cc b/google_apis/gaia/gaia_auth_fetcher_unittest.cc index 27773999d409ba..33441aff380206 100644 --- a/google_apis/gaia/gaia_auth_fetcher_unittest.cc +++ b/google_apis/gaia/gaia_auth_fetcher_unittest.cc @@ -194,9 +194,6 @@ class MockGaiaConsumer : public GaiaAuthConsumer { MOCK_METHOD0(OnLogOutSuccess, void()); MOCK_METHOD1(OnLogOutFailure, void(const GoogleServiceAuthError& error)); MOCK_METHOD1(OnGetCheckConnectionInfoSuccess, void(const std::string& data)); - MOCK_METHOD1(OnListIdpSessionsSuccess, void(const std::string& data)); - MOCK_METHOD1(OnGetTokenResponseSuccess, - void(const GaiaAuthConsumer::ClientOAuthResult& result)); }; #if defined(OS_WIN) diff --git a/google_apis/gaia/gaia_urls.cc b/google_apis/gaia/gaia_urls.cc index c76928a974ead3..8990324c0755d9 100644 --- a/google_apis/gaia/gaia_urls.cc +++ b/google_apis/gaia/gaia_urls.cc @@ -43,7 +43,6 @@ const char kDeprecatedClientLoginToOAuth2UrlSuffix[] = "o/oauth2/programmatic_auth"; const char kOAuth2AuthUrlSuffix[] = "o/oauth2/auth"; const char kOAuth2RevokeUrlSuffix[] = "o/oauth2/revoke"; -const char kOAuth2IFrameUrlSuffix[] = "o/oauth2/iframerpc"; // API calls from www.googleapis.com const char kOAuth2TokenUrlSuffix[] = "oauth2/v4/token"; @@ -126,8 +125,6 @@ GaiaUrls::GaiaUrls() { lso_origin_url_.Resolve(kDeprecatedClientLoginToOAuth2UrlSuffix); oauth2_auth_url_ = lso_origin_url_.Resolve(kOAuth2AuthUrlSuffix); oauth2_revoke_url_ = lso_origin_url_.Resolve(kOAuth2RevokeUrlSuffix); - oauth2_iframe_url_ = - lso_origin_url_.Resolve(kOAuth2IFrameUrlSuffix); // URLs from www.googleapis.com. oauth2_token_url_ = google_apis_origin_url_.Resolve(kOAuth2TokenUrlSuffix); @@ -218,10 +215,6 @@ const GURL& GaiaUrls::oauth_revoke_token_url() const { return oauth_revoke_token_url_; } -const GURL& GaiaUrls::oauth2_iframe_url() const { - return oauth2_iframe_url_; -} - const GURL& GaiaUrls::oauth1_login_url() const { return oauth1_login_url_; } diff --git a/google_apis/gaia/gaia_urls.h b/google_apis/gaia/gaia_urls.h index 42f6516978bd1f..9bb3751e99a13d 100644 --- a/google_apis/gaia/gaia_urls.h +++ b/google_apis/gaia/gaia_urls.h @@ -46,7 +46,6 @@ class GaiaUrls { const GURL& oauth2_issue_token_url() const; const GURL& oauth2_token_info_url() const; const GURL& oauth2_revoke_url() const; - const GURL& oauth2_iframe_url() const; const GURL& gaia_login_form_realm() const; @@ -100,7 +99,6 @@ class GaiaUrls { GURL oauth2_issue_token_url_; GURL oauth2_token_info_url_; GURL oauth2_revoke_url_; - GURL oauth2_iframe_url_; GURL gaia_login_form_realm_;