diff options
author | johnnyg@chromium.org <johnnyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-02 23:38:39 +0000 |
---|---|---|
committer | johnnyg@chromium.org <johnnyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-02 23:38:39 +0000 |
commit | 7622ff461bb322e7dd8328ae19551bbdbc43559f (patch) | |
tree | 1a954e14548d218012cd7109faf24eaabec9920e | |
parent | 85aef0f2e451067b729eab19c6d1f1e796f7fa04 (diff) | |
download | chromium_src-7622ff461bb322e7dd8328ae19551bbdbc43559f.zip chromium_src-7622ff461bb322e7dd8328ae19551bbdbc43559f.tar.gz chromium_src-7622ff461bb322e7dd8328ae19551bbdbc43559f.tar.bz2 |
Sync shouldn't allow hosted accounts, but other clients of GaiaAuthenticator2 still should.
BUG=chromiumos:7296
TEST=see bug
Review URL: http://codereview.chromium.org/3599010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61318 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/chromeos/login/google_authenticator.cc | 13 | ||||
-rw-r--r-- | chrome/browser/chromeos/login/online_attempt.cc | 12 | ||||
-rw-r--r-- | chrome/browser/printing/cloud_print/cloud_print_setup_flow.cc | 3 | ||||
-rw-r--r-- | chrome/browser/remoting/remoting_setup_flow.cc | 3 | ||||
-rw-r--r-- | chrome/browser/sync/signin_manager.cc | 3 | ||||
-rw-r--r-- | chrome/common/net/gaia/gaia_authenticator2.cc | 36 | ||||
-rw-r--r-- | chrome/common/net/gaia/gaia_authenticator2.h | 25 | ||||
-rw-r--r-- | chrome/common/net/gaia/gaia_authenticator2_unittest.cc | 9 |
8 files changed, 68 insertions, 36 deletions
diff --git a/chrome/browser/chromeos/login/google_authenticator.cc b/chrome/browser/chromeos/login/google_authenticator.cc index f6e53b4..7152a51 100644 --- a/chrome/browser/chromeos/login/google_authenticator.cc +++ b/chrome/browser/chromeos/login/google_authenticator.cc @@ -82,11 +82,14 @@ void GoogleAuthenticator::CancelClientLogin() { } void GoogleAuthenticator::TryClientLogin() { - gaia_authenticator_->StartClientLogin(username_, - password_, - GaiaConstants::kContactsService, - login_token_, - login_captcha_); + gaia_authenticator_->StartClientLogin( + username_, + password_, + GaiaConstants::kContactsService, + login_token_, + login_captcha_, + GaiaAuthenticator2::HostedAccountsAllowed); + ChromeThread::PostDelayedTask( ChromeThread::UI, FROM_HERE, diff --git a/chrome/browser/chromeos/login/online_attempt.cc b/chrome/browser/chromeos/login/online_attempt.cc index 9cd1a3e..690f681 100644 --- a/chrome/browser/chromeos/login/online_attempt.cc +++ b/chrome/browser/chromeos/login/online_attempt.cc @@ -98,11 +98,13 @@ void OnlineAttempt::TryClientLogin() { ChromeThread::PostDelayedTask(ChromeThread::IO, FROM_HERE, fetch_canceler_, kClientLoginTimeoutMs); - gaia_authenticator_->StartClientLogin(attempt_->username, - attempt_->password, - GaiaConstants::kContactsService, - attempt_->login_token, - attempt_->login_captcha); + gaia_authenticator_->StartClientLogin( + attempt_->username, + attempt_->password, + GaiaConstants::kContactsService, + attempt_->login_token, + attempt_->login_captcha, + GaiaAuthenticator2::HostedAccountsAllowed); } void OnlineAttempt::CancelClientLogin() { diff --git a/chrome/browser/printing/cloud_print/cloud_print_setup_flow.cc b/chrome/browser/printing/cloud_print/cloud_print_setup_flow.cc index 54fcab6..2dfc19f 100644 --- a/chrome/browser/printing/cloud_print/cloud_print_setup_flow.cc +++ b/chrome/browser/printing/cloud_print/cloud_print_setup_flow.cc @@ -389,7 +389,8 @@ void CloudPrintSetupFlow::OnUserSubmittedAuth(const std::string& user, profile_->GetRequestContext())); authenticator_->StartClientLogin(user, password, GaiaConstants::kCloudPrintService, - "", captcha); + "", captcha, + GaiaAuthenticator2::HostedAccountsAllowed); } /////////////////////////////////////////////////////////////////////////////// diff --git a/chrome/browser/remoting/remoting_setup_flow.cc b/chrome/browser/remoting/remoting_setup_flow.cc index 4a982db..856fd72 100644 --- a/chrome/browser/remoting/remoting_setup_flow.cc +++ b/chrome/browser/remoting/remoting_setup_flow.cc @@ -250,7 +250,8 @@ void RemotingSetupFlow::OnUserSubmittedAuth(const std::string& user, profile_->GetRequestContext())); authenticator_->StartClientLogin(user, password, GaiaConstants::kRemotingService, - "", captcha); + "", captcha, + GaiaAuthenticator2::HostedAccountsAllowed); } /////////////////////////////////////////////////////////////////////////////// diff --git a/chrome/browser/sync/signin_manager.cc b/chrome/browser/sync/signin_manager.cc index ba71c1f..109d364 100644 --- a/chrome/browser/sync/signin_manager.cc +++ b/chrome/browser/sync/signin_manager.cc @@ -57,7 +57,8 @@ void SigninManager::StartSignIn(const std::string& username, password, "", login_token, - login_captcha); + login_captcha, + GaiaAuthenticator2::HostedAccountsNotAllowed); } void SigninManager::SignOut() { diff --git a/chrome/common/net/gaia/gaia_authenticator2.cc b/chrome/common/net/gaia/gaia_authenticator2.cc index 479aa28..03a00928 100644 --- a/chrome/common/net/gaia/gaia_authenticator2.cc +++ b/chrome/common/net/gaia/gaia_authenticator2.cc @@ -71,9 +71,13 @@ const char GaiaAuthenticator2::kCaptchaUrlPrefix[] = // static const char GaiaAuthenticator2::kCookiePersistence[] = "true"; // static -// TODO(johnnyg): When hosted accounts are supported, this can become -// "HOSTED_OR_GOOGLE". http://crbug.com/19589 -const char GaiaAuthenticator2::kAccountType[] = "GOOGLE"; +// TODO(johnnyg): When hosted accounts are supported by sync, +// we can always use "HOSTED_OR_GOOGLE" +const char GaiaAuthenticator2::kAccountTypeHostedOrGoogle[] = + "HOSTED_OR_GOOGLE"; +const char GaiaAuthenticator2::kAccountTypeGoogle[] = + "GOOGLE"; + // static const char GaiaAuthenticator2::kSecondFactor[] = "Info=InvalidSecondFactor"; @@ -133,18 +137,23 @@ std::string GaiaAuthenticator2::MakeClientLoginBody( const std::string& source, const char* service, const std::string& login_token, - const std::string& login_captcha) { + const std::string& login_captcha, + HostedAccountsSetting allow_hosted_accounts) { std::string encoded_username = UrlEncodeString(username); std::string encoded_password = UrlEncodeString(password); std::string encoded_login_token = UrlEncodeString(login_token); std::string encoded_login_captcha = UrlEncodeString(login_captcha); + const char* account_type = allow_hosted_accounts == HostedAccountsAllowed ? + kAccountTypeHostedOrGoogle : + kAccountTypeGoogle; + if (login_token.empty() || login_captcha.empty()) { return StringPrintf(kClientLoginFormat, encoded_username.c_str(), encoded_password.c_str(), kCookiePersistence, - kAccountType, + account_type, source.c_str(), service); } @@ -153,7 +162,7 @@ std::string GaiaAuthenticator2::MakeClientLoginBody( encoded_username.c_str(), encoded_password.c_str(), kCookiePersistence, - kAccountType, + account_type, source.c_str(), service, encoded_login_token.c_str(), @@ -231,11 +240,13 @@ void GaiaAuthenticator2::ParseClientLoginFailure(const std::string& data, } } -void GaiaAuthenticator2::StartClientLogin(const std::string& username, - const std::string& password, - const char* const service, - const std::string& login_token, - const std::string& login_captcha) { +void GaiaAuthenticator2::StartClientLogin( + const std::string& username, + const std::string& password, + const char* const service, + const std::string& login_token, + const std::string& login_captcha, + HostedAccountsSetting allow_hosted_accounts) { DCHECK(!fetch_pending_) << "Tried to fetch two things at once!"; @@ -249,7 +260,8 @@ void GaiaAuthenticator2::StartClientLogin(const std::string& username, source_, service, login_token, - login_captcha); + login_captcha, + allow_hosted_accounts); fetcher_.reset(CreateGaiaFetcher(getter_, request_body_, client_login_gurl_, diff --git a/chrome/common/net/gaia/gaia_authenticator2.h b/chrome/common/net/gaia/gaia_authenticator2.h index 7c01b40..fece7db 100644 --- a/chrome/common/net/gaia/gaia_authenticator2.h +++ b/chrome/common/net/gaia/gaia_authenticator2.h @@ -29,6 +29,11 @@ class GaiaAuthenticator2Test; // TODO(chron): Rename this to GaiaAuthFetcher or something. class GaiaAuthenticator2 : public URLFetcher::Delegate { public: + enum HostedAccountsSetting { + HostedAccountsAllowed, + HostedAccountsNotAllowed + }; + // The URLs for different calls in the Google Accounts programmatic login API. static const char kClientLoginUrl[]; static const char kIssueAuthTokenUrl[]; @@ -52,7 +57,8 @@ class GaiaAuthenticator2 : public URLFetcher::Delegate { const std::string& password, const char* const service, const std::string& login_token, - const std::string& login_captcha); + const std::string& login_captcha, + HostedAccountsSetting allow_hosted_accounts); // GaiaAuthConsumer will be called on the original thread // after results come back. This class is thread agnostic. @@ -85,7 +91,8 @@ class GaiaAuthenticator2 : public URLFetcher::Delegate { private: // ClientLogin body constants that don't change static const char kCookiePersistence[]; - static const char kAccountType[]; + static const char kAccountTypeHostedOrGoogle[]; + static const char kAccountTypeGoogle[]; // The format of the POST body for ClientLogin. static const char kClientLoginFormat[]; @@ -143,12 +150,14 @@ class GaiaAuthenticator2 : public URLFetcher::Delegate { static bool IsSecondFactorSuccess(const std::string& alleged_error); // Given parameters, create a ClientLogin request body. - static std::string MakeClientLoginBody(const std::string& username, - const std::string& password, - const std::string& source, - const char* const service, - const std::string& login_token, - const std::string& login_captcha); + static std::string MakeClientLoginBody( + const std::string& username, + const std::string& password, + const std::string& source, + const char* const service, + const std::string& login_token, + const std::string& login_captcha, + HostedAccountsSetting allow_hosted_accounts); // Supply the sid / lsid returned from ClientLogin in order to // request a long lived auth token for a service. static std::string MakeIssueAuthTokenBody(const std::string& sid, diff --git a/chrome/common/net/gaia/gaia_authenticator2_unittest.cc b/chrome/common/net/gaia/gaia_authenticator2_unittest.cc index ea17325..44d1a17 100644 --- a/chrome/common/net/gaia/gaia_authenticator2_unittest.cc +++ b/chrome/common/net/gaia/gaia_authenticator2_unittest.cc @@ -336,7 +336,8 @@ TEST_F(GaiaAuthenticator2Test, FullLogin) { "password", "service", std::string(), - std::string()); + std::string(), + GaiaAuthenticator2::HostedAccountsAllowed); URLFetcher::set_factory(NULL); } @@ -358,7 +359,8 @@ TEST_F(GaiaAuthenticator2Test, FullLoginFailure) { "password", "service", std::string(), - std::string()); + std::string(), + GaiaAuthenticator2::HostedAccountsAllowed); URLFetcher::set_factory(NULL); } @@ -378,7 +380,8 @@ TEST_F(GaiaAuthenticator2Test, ClientFetchPending) { "password", "service", std::string(), - std::string()); + std::string(), + GaiaAuthenticator2::HostedAccountsAllowed); URLFetcher::set_factory(NULL); EXPECT_TRUE(auth.HasPendingFetch()); |