OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h" |
6 | 6 |
7 #include "ash/system/chromeos/devicetype_utils.h" | 7 #include "ash/system/chromeos/devicetype_utils.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/guid.h" | 9 #include "base/guid.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 else | 473 else |
474 frame_error_ = net::ERR_INTERNET_DISCONNECTED; | 474 frame_error_ = net::ERR_INTERNET_DISCONNECTED; |
475 | 475 |
476 LOG(ERROR) << "Gaia webview error: " << error_reason_str; | 476 LOG(ERROR) << "Gaia webview error: " << error_reason_str; |
477 NetworkError::ErrorReason error_reason = | 477 NetworkError::ErrorReason error_reason = |
478 NetworkError::ERROR_REASON_FRAME_ERROR; | 478 NetworkError::ERROR_REASON_FRAME_ERROR; |
479 frame_state_ = FRAME_STATE_ERROR; | 479 frame_state_ = FRAME_STATE_ERROR; |
480 UpdateState(error_reason); | 480 UpdateState(error_reason); |
481 } | 481 } |
482 | 482 |
| 483 std::string GaiaScreenHandler::GetCanonicalEmail( |
| 484 const std::string& authenticated_email, |
| 485 const std::string& gaia_id) const { |
| 486 const std::string sanitized_email = gaia::SanitizeEmail(authenticated_email); |
| 487 |
| 488 const std::string canonicalized_email = |
| 489 gaia::CanonicalizeEmail(sanitized_email); |
| 490 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
| 491 if (user_manager && !user_manager->IsKnownUser(canonicalized_email)) { |
| 492 std::string old_canonical_email; |
| 493 if (user_manager->GetKnownUserCanonicalEmail(gaia_id, |
| 494 &old_canonical_email)) { |
| 495 if (old_canonical_email != canonicalized_email) { |
| 496 LOG(WARNING) << "Existing user '" << old_canonical_email |
| 497 << "' authenticated by alias '" << sanitized_email << "'."; |
| 498 return old_canonical_email; |
| 499 } |
| 500 } |
| 501 } |
| 502 // For compatibility reasons, sanitized email is used. |
| 503 return sanitized_email; |
| 504 } |
| 505 |
483 void GaiaScreenHandler::HandleCompleteAuthentication( | 506 void GaiaScreenHandler::HandleCompleteAuthentication( |
484 const std::string& gaia_id, | 507 const std::string& gaia_id, |
485 const std::string& email, | 508 const std::string& email, |
486 const std::string& password, | 509 const std::string& password, |
487 const std::string& auth_code, | 510 const std::string& auth_code, |
488 bool using_saml, | 511 bool using_saml, |
489 const std::string& gaps_cookie) { | 512 const std::string& gaps_cookie) { |
490 if (!Delegate()) | 513 if (!Delegate()) |
491 return; | 514 return; |
492 | 515 |
493 DCHECK(!email.empty()); | 516 DCHECK(!email.empty()); |
494 DCHECK(!gaia_id.empty()); | 517 DCHECK(!gaia_id.empty()); |
495 const std::string sanitized_email = gaia::SanitizeEmail(email); | 518 const std::string sanitized_email = gaia::SanitizeEmail(email); |
496 Delegate()->SetDisplayEmail(sanitized_email); | 519 Delegate()->SetDisplayEmail(sanitized_email); |
497 UserContext user_context(sanitized_email); | 520 |
| 521 const std::string canonical_email = GetCanonicalEmail(email, gaia_id); |
| 522 UserContext user_context(canonical_email); |
498 user_context.SetGaiaID(gaia_id); | 523 user_context.SetGaiaID(gaia_id); |
499 user_context.SetKey(Key(password)); | 524 user_context.SetKey(Key(password)); |
500 user_context.SetAuthCode(auth_code); | 525 user_context.SetAuthCode(auth_code); |
501 user_context.SetAuthFlow(using_saml | 526 user_context.SetAuthFlow(using_saml |
502 ? UserContext::AUTH_FLOW_GAIA_WITH_SAML | 527 ? UserContext::AUTH_FLOW_GAIA_WITH_SAML |
503 : UserContext::AUTH_FLOW_GAIA_WITHOUT_SAML); | 528 : UserContext::AUTH_FLOW_GAIA_WITHOUT_SAML); |
504 user_context.SetGAPSCookie(gaps_cookie); | 529 user_context.SetGAPSCookie(gaps_cookie); |
505 Delegate()->CompleteLogin(user_context); | 530 Delegate()->CompleteLogin(user_context); |
506 } | 531 } |
507 | 532 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 if (!Delegate()) | 633 if (!Delegate()) |
609 return; | 634 return; |
610 | 635 |
611 if (using_saml && !using_saml_api_) | 636 if (using_saml && !using_saml_api_) |
612 RecordSAMLScrapingVerificationResultInHistogram(true); | 637 RecordSAMLScrapingVerificationResultInHistogram(true); |
613 | 638 |
614 DCHECK(!typed_email.empty()); | 639 DCHECK(!typed_email.empty()); |
615 DCHECK(!gaia_id.empty()); | 640 DCHECK(!gaia_id.empty()); |
616 const std::string sanitized_email = gaia::SanitizeEmail(typed_email); | 641 const std::string sanitized_email = gaia::SanitizeEmail(typed_email); |
617 Delegate()->SetDisplayEmail(sanitized_email); | 642 Delegate()->SetDisplayEmail(sanitized_email); |
618 UserContext user_context(sanitized_email); | 643 const std::string canonical_email = GetCanonicalEmail(typed_email, gaia_id); |
| 644 UserContext user_context(canonical_email); |
619 user_context.SetGaiaID(gaia_id); | 645 user_context.SetGaiaID(gaia_id); |
620 user_context.SetKey(Key(password)); | 646 user_context.SetKey(Key(password)); |
621 user_context.SetAuthFlow(using_saml | 647 user_context.SetAuthFlow(using_saml |
622 ? UserContext::AUTH_FLOW_GAIA_WITH_SAML | 648 ? UserContext::AUTH_FLOW_GAIA_WITH_SAML |
623 : UserContext::AUTH_FLOW_GAIA_WITHOUT_SAML); | 649 : UserContext::AUTH_FLOW_GAIA_WITHOUT_SAML); |
624 Delegate()->CompleteLogin(user_context); | 650 Delegate()->CompleteLogin(user_context); |
625 | 651 |
626 if (test_expects_complete_login_) { | 652 if (test_expects_complete_login_) { |
627 VLOG(2) << "Complete test login for " << typed_email | 653 VLOG(2) << "Complete test login for " << typed_email |
628 << ", requested=" << test_user_; | 654 << ", requested=" << test_user_; |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
886 SigninScreenHandlerDelegate* GaiaScreenHandler::Delegate() { | 912 SigninScreenHandlerDelegate* GaiaScreenHandler::Delegate() { |
887 return signin_screen_handler_->delegate_; | 913 return signin_screen_handler_->delegate_; |
888 } | 914 } |
889 | 915 |
890 bool GaiaScreenHandler::IsRestrictiveProxy() const { | 916 bool GaiaScreenHandler::IsRestrictiveProxy() const { |
891 return captive_portal_status_ == | 917 return captive_portal_status_ == |
892 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL; | 918 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL; |
893 } | 919 } |
894 | 920 |
895 } // namespace chromeos | 921 } // namespace chromeos |
OLD | NEW |