Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Unified Diff: google_apis/gaia/fake_gaia.cc

Issue 677703002: Revert of Revert of Inline sign in extracts gaia id from HTTP header and seeds account tracker (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: google_apis/gaia/fake_gaia.cc
diff --git a/google_apis/gaia/fake_gaia.cc b/google_apis/gaia/fake_gaia.cc
index 9c4836f5e2b46f694694805281b1d3522e0d132d..b1a3942c1c505efa1484134650d8793abf03841b 100644
--- a/google_apis/gaia/fake_gaia.cc
+++ b/google_apis/gaia/fake_gaia.cc
@@ -51,6 +51,8 @@
const char kTestOAuthLoginLSID[] = "fake-oauth-LSID-cookie";
const char kTestOAuthLoginAuthCode[] = "fake-oauth-auth-code";
+const char kDefaultGaiaId[] ="12345";
+
const base::FilePath::CharType kServiceLogin[] =
FILE_PATH_LITERAL("google_apis/test/service_login.html");
@@ -163,6 +165,30 @@
merge_session_params_ = params;
}
+void FakeGaia::MapEmailToGaiaId(const std::string& email,
+ const std::string& gaia_id) {
+ DCHECK(!email.empty());
+ DCHECK(!gaia_id.empty());
+ email_to_gaia_id_map_[email] = gaia_id;
+}
+
+std::string FakeGaia::GetGaiaIdOfEmail(const std::string& email) const {
+ DCHECK(!email.empty());
+ auto it = email_to_gaia_id_map_.find(email);
+ return it == email_to_gaia_id_map_.end() ? std::string(kDefaultGaiaId) :
+ it->second;
+}
+
+void FakeGaia::AddGoogleAccountsSigninHeader(
+ net::test_server::BasicHttpResponse* http_response,
+ const std::string& email) const {
+ DCHECK(!email.empty());
+ http_response->AddCustomHeader("google-accounts-signin",
+ base::StringPrintf(
+ "email=\"%s\", obfuscatedid=\"%s\", sessionindex=0",
+ email.c_str(), GetGaiaIdOfEmail(email).c_str()));
+}
+
void FakeGaia::Initialize() {
GaiaUrls* gaia_urls = GaiaUrls::GetInstance();
// Handles /MergeSession GAIA call.
@@ -415,8 +441,11 @@
std::string redirect_url = continue_url;
std::string email;
- if (GetQueryParameter(request.content, "Email", &email) &&
- saml_account_idp_map_.find(email) != saml_account_idp_map_.end()) {
+ const bool is_saml =
+ GetQueryParameter(request.content, "Email", &email) &&
+ saml_account_idp_map_.find(email) != saml_account_idp_map_.end();
+
+ if (is_saml) {
GURL url(saml_account_idp_map_[email]);
url = net::AppendQueryParameter(url, "SAMLRequest", "fake_request");
url = net::AppendQueryParameter(url, "RelayState", continue_url);
@@ -431,8 +460,12 @@
http_response->set_code(net::HTTP_TEMPORARY_REDIRECT);
http_response->AddCustomHeader("Location", redirect_url);
- http_response->AddCustomHeader("google-accounts-signin",
- base::StringPrintf("email=\"%s\", sessionindex=0", email.c_str()));
+
+ // SAML sign-ins complete in HandleSSO().
+ if (is_saml)
+ return;
+
+ AddGoogleAccountsSigninHeader(http_response, email);
}
void FakeGaia::HandleSSO(const HttpRequest& request,
@@ -449,6 +482,9 @@
http_response->set_code(net::HTTP_TEMPORARY_REDIRECT);
http_response->AddCustomHeader("Location", redirect_url);
http_response->AddCustomHeader("Google-Accounts-SAML", "End");
+
+ if (!merge_session_params_.email.empty())
+ AddGoogleAccountsSigninHeader(http_response, merge_session_params_.email);
}
void FakeGaia::HandleAuthToken(const HttpRequest& request,
@@ -580,3 +616,4 @@
merge_session_params_.email.c_str()));
http_response->set_code(net::HTTP_OK);
}
+
« no previous file with comments | « google_apis/gaia/fake_gaia.h ('k') | tools/telemetry/telemetry/core/backends/chrome/chromeos_login_ext/main.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698