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

Side by Side Diff: chrome/browser/chromeos/login/session/user_session_manager.cc

Issue 1021383002: cros: Transfer auth cookies for SAML webview sign-in. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update comment Created 5 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/chromeos/login/session/user_session_manager.h" 5 #include "chrome/browser/chromeos/login/session/user_session_manager.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/base_paths.h" 9 #include "base/base_paths.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 16 matching lines...) Expand all
27 #include "chrome/browser/chrome_notification_types.h" 27 #include "chrome/browser/chrome_notification_types.h"
28 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" 28 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
29 #include "chrome/browser/chromeos/base/locale_util.h" 29 #include "chrome/browser/chromeos/base/locale_util.h"
30 #include "chrome/browser/chromeos/boot_times_recorder.h" 30 #include "chrome/browser/chromeos/boot_times_recorder.h"
31 #include "chrome/browser/chromeos/first_run/first_run.h" 31 #include "chrome/browser/chromeos/first_run/first_run.h"
32 #include "chrome/browser/chromeos/input_method/input_method_util.h" 32 #include "chrome/browser/chromeos/input_method/input_method_util.h"
33 #include "chrome/browser/chromeos/login/auth/chrome_cryptohome_authenticator.h" 33 #include "chrome/browser/chromeos/login/auth/chrome_cryptohome_authenticator.h"
34 #include "chrome/browser/chromeos/login/chrome_restart_request.h" 34 #include "chrome/browser/chromeos/login/chrome_restart_request.h"
35 #include "chrome/browser/chromeos/login/demo_mode/demo_app_launcher.h" 35 #include "chrome/browser/chromeos/login/demo_mode/demo_app_launcher.h"
36 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h" 36 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h"
37 #include "chrome/browser/chromeos/login/helper.h"
37 #include "chrome/browser/chromeos/login/lock/screen_locker.h" 38 #include "chrome/browser/chromeos/login/lock/screen_locker.h"
38 #include "chrome/browser/chromeos/login/profile_auth_data.h" 39 #include "chrome/browser/chromeos/login/profile_auth_data.h"
39 #include "chrome/browser/chromeos/login/saml/saml_offline_signin_limiter.h" 40 #include "chrome/browser/chromeos/login/saml/saml_offline_signin_limiter.h"
40 #include "chrome/browser/chromeos/login/saml/saml_offline_signin_limiter_factory .h" 41 #include "chrome/browser/chromeos/login/saml/saml_offline_signin_limiter_factory .h"
41 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager.h" 42 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager.h"
42 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager_factory.h" 43 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager_factory.h"
43 #include "chrome/browser/chromeos/login/startup_utils.h" 44 #include "chrome/browser/chromeos/login/startup_utils.h"
44 #include "chrome/browser/chromeos/login/ui/input_events_blocker.h" 45 #include "chrome/browser/chromeos/login/ui/input_events_blocker.h"
45 #include "chrome/browser/chromeos/login/ui/login_display_host.h" 46 #include "chrome/browser/chromeos/login/ui/login_display_host.h"
46 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" 47 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h"
(...skipping 18 matching lines...) Expand all
65 #include "chrome/browser/signin/account_tracker_service_factory.h" 66 #include "chrome/browser/signin/account_tracker_service_factory.h"
66 #include "chrome/browser/signin/easy_unlock_service.h" 67 #include "chrome/browser/signin/easy_unlock_service.h"
67 #include "chrome/browser/signin/signin_manager_factory.h" 68 #include "chrome/browser/signin/signin_manager_factory.h"
68 #include "chrome/browser/supervised_user/child_accounts/child_account_service.h" 69 #include "chrome/browser/supervised_user/child_accounts/child_account_service.h"
69 #include "chrome/browser/supervised_user/child_accounts/child_account_service_fa ctory.h" 70 #include "chrome/browser/supervised_user/child_accounts/child_account_service_fa ctory.h"
70 #include "chrome/browser/ui/app_list/start_page_service.h" 71 #include "chrome/browser/ui/app_list/start_page_service.h"
71 #include "chrome/browser/ui/startup/startup_browser_creator.h" 72 #include "chrome/browser/ui/startup/startup_browser_creator.h"
72 #include "chrome/common/chrome_switches.h" 73 #include "chrome/common/chrome_switches.h"
73 #include "chrome/common/logging_chrome.h" 74 #include "chrome/common/logging_chrome.h"
74 #include "chrome/common/pref_names.h" 75 #include "chrome/common/pref_names.h"
75 #include "chrome/common/url_constants.h"
76 #include "chromeos/cert_loader.h" 76 #include "chromeos/cert_loader.h"
77 #include "chromeos/chromeos_switches.h" 77 #include "chromeos/chromeos_switches.h"
78 #include "chromeos/cryptohome/cryptohome_util.h" 78 #include "chromeos/cryptohome/cryptohome_util.h"
79 #include "chromeos/dbus/cryptohome_client.h" 79 #include "chromeos/dbus/cryptohome_client.h"
80 #include "chromeos/dbus/dbus_thread_manager.h" 80 #include "chromeos/dbus/dbus_thread_manager.h"
81 #include "chromeos/dbus/session_manager_client.h" 81 #include "chromeos/dbus/session_manager_client.h"
82 #include "chromeos/login/auth/stub_authenticator.h" 82 #include "chromeos/login/auth/stub_authenticator.h"
83 #include "chromeos/login/user_names.h" 83 #include "chromeos/login/user_names.h"
84 #include "chromeos/network/portal_detector/network_portal_detector.h" 84 #include "chromeos/network/portal_detector/network_portal_detector.h"
85 #include "chromeos/network/portal_detector/network_portal_detector_strategy.h" 85 #include "chromeos/network/portal_detector/network_portal_detector_strategy.h"
(...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after
967 // transferred unconditionally. If the user authenticated via an auth 967 // transferred unconditionally. If the user authenticated via an auth
968 // extension, authentication cookies and channel IDs will be transferred as 968 // extension, authentication cookies and channel IDs will be transferred as
969 // well when the user's cookie jar is empty. If the cookie jar is not empty, 969 // well when the user's cookie jar is empty. If the cookie jar is not empty,
970 // the authentication states in the browser context and the user's profile 970 // the authentication states in the browser context and the user's profile
971 // must be merged using /MergeSession instead. Authentication cookies set by 971 // must be merged using /MergeSession instead. Authentication cookies set by
972 // a SAML IdP will also be transferred when the user's cookie jar is not 972 // a SAML IdP will also be transferred when the user's cookie jar is not
973 // empty if |transfer_saml_auth_cookies_on_subsequent_login| is true. 973 // empty if |transfer_saml_auth_cookies_on_subsequent_login| is true.
974 const bool transfer_auth_cookies_and_channel_ids_on_first_login = 974 const bool transfer_auth_cookies_and_channel_ids_on_first_login =
975 has_auth_cookies_; 975 has_auth_cookies_;
976 ProfileAuthData::Transfer( 976 ProfileAuthData::Transfer(
977 authenticator_->authentication_context(), 977 GetAuthRequestContext(),
978 profile, 978 profile->GetRequestContext(),
979 transfer_auth_cookies_and_channel_ids_on_first_login, 979 transfer_auth_cookies_and_channel_ids_on_first_login,
980 transfer_saml_auth_cookies_on_subsequent_login, 980 transfer_saml_auth_cookies_on_subsequent_login,
981 base::Bind(&UserSessionManager::CompleteProfileCreateAfterAuthTransfer, 981 base::Bind(&UserSessionManager::CompleteProfileCreateAfterAuthTransfer,
982 AsWeakPtr(), 982 AsWeakPtr(),
983 profile)); 983 profile));
984 return; 984 return;
985 } 985 }
986 986
987 FinalizePrepareProfile(profile); 987 FinalizePrepareProfile(profile);
988 } 988 }
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 } 1197 }
1198 1198
1199 exit_after_session_restore_ = false; 1199 exit_after_session_restore_ = false;
1200 1200
1201 // Remove legacy OAuth1 token if we have one. If it's valid, we should already 1201 // Remove legacy OAuth1 token if we have one. If it's valid, we should already
1202 // have OAuth2 refresh token in OAuth2TokenService that could be used to 1202 // have OAuth2 refresh token in OAuth2TokenService that could be used to
1203 // retrieve all other tokens and user_context. 1203 // retrieve all other tokens and user_context.
1204 OAuth2LoginManager* login_manager = 1204 OAuth2LoginManager* login_manager =
1205 OAuth2LoginManagerFactory::GetInstance()->GetForProfile(profile); 1205 OAuth2LoginManagerFactory::GetInstance()->GetForProfile(profile);
1206 login_manager->AddObserver(this); 1206 login_manager->AddObserver(this);
1207 net::URLRequestContextGetter* auth_request_context = NULL;
1208 1207
1209 if (StartupUtils::IsWebviewSigninEnabled()) { 1208 login_manager->RestoreSession(
1210 // Webview uses different partition storage than iframe. We need to get 1209 GetAuthRequestContext(), session_restore_strategy_,
1211 // cookies from the right storage for url request to get auth token into 1210 user_context_.GetRefreshToken(), user_context_.GetAuthCode());
1212 // session.
1213 GURL oobe_url(chrome::kChromeUIOobeURL);
1214 GURL guest_url(std::string(content::kGuestScheme) +
1215 url::kStandardSchemeSeparator + oobe_url.GetContent());
1216 content::StoragePartition* partition =
1217 content::BrowserContext::GetStoragePartitionForSite(
1218 ProfileHelper::GetSigninProfile(), guest_url);
1219 auth_request_context = partition->GetURLRequestContext();
1220 } else if (authenticator_.get() && authenticator_->authentication_context()) {
1221 auth_request_context =
1222 authenticator_->authentication_context()->GetRequestContext();
1223 }
1224
1225 login_manager->RestoreSession(auth_request_context, session_restore_strategy_,
1226 user_context_.GetRefreshToken(),
1227 user_context_.GetAuthCode());
1228 } 1211 }
1229 1212
1230 void UserSessionManager::InitRlzImpl(Profile* profile, bool disabled) { 1213 void UserSessionManager::InitRlzImpl(Profile* profile, bool disabled) {
1231 #if defined(ENABLE_RLZ) 1214 #if defined(ENABLE_RLZ)
1232 PrefService* local_state = g_browser_process->local_state(); 1215 PrefService* local_state = g_browser_process->local_state();
1233 if (disabled) { 1216 if (disabled) {
1234 // Empty brand code means an organic install (no RLZ pings are sent). 1217 // Empty brand code means an organic install (no RLZ pings are sent).
1235 google_brand::chromeos::ClearBrandForCurrentSession(); 1218 google_brand::chromeos::ClearBrandForCurrentSession();
1236 } 1219 }
1237 if (disabled != local_state->GetBoolean(prefs::kRLZDisabled)) { 1220 if (disabled != local_state->GetBoolean(prefs::kRLZDisabled)) {
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1404 device_list = &empty_list; 1387 device_list = &empty_list;
1405 1388
1406 EasyUnlockKeyManager* key_manager = GetEasyUnlockKeyManager(); 1389 EasyUnlockKeyManager* key_manager = GetEasyUnlockKeyManager();
1407 running_easy_unlock_key_ops_ = true; 1390 running_easy_unlock_key_ops_ = true;
1408 key_manager->RefreshKeys( 1391 key_manager->RefreshKeys(
1409 user_context, *device_list, 1392 user_context, *device_list,
1410 base::Bind(&UserSessionManager::OnEasyUnlockKeyOpsFinished, AsWeakPtr(), 1393 base::Bind(&UserSessionManager::OnEasyUnlockKeyOpsFinished, AsWeakPtr(),
1411 user_context.GetUserID())); 1394 user_context.GetUserID()));
1412 } 1395 }
1413 1396
1397 net::URLRequestContextGetter*
1398 UserSessionManager::GetAuthRequestContext() const {
1399 net::URLRequestContextGetter* auth_request_context = NULL;
1400
1401 if (StartupUtils::IsWebviewSigninEnabled()) {
1402 // Webview uses different partition storage than iframe. We need to get
1403 // cookies from the right storage for url request to get auth token into
1404 // session.
1405 auth_request_context = login::GetSigninPartition()->GetURLRequestContext();
1406 } else if (authenticator_.get() && authenticator_->authentication_context()) {
1407 auth_request_context =
1408 authenticator_->authentication_context()->GetRequestContext();
1409 }
1410 return auth_request_context;
1411 }
1412
1414 void UserSessionManager::AttemptRestart(Profile* profile) { 1413 void UserSessionManager::AttemptRestart(Profile* profile) {
1415 if (CheckEasyUnlockKeyOps(base::Bind(&UserSessionManager::AttemptRestart, 1414 if (CheckEasyUnlockKeyOps(base::Bind(&UserSessionManager::AttemptRestart,
1416 AsWeakPtr(), profile))) { 1415 AsWeakPtr(), profile))) {
1417 return; 1416 return;
1418 } 1417 }
1419 1418
1420 if (session_restore_strategy_ != 1419 if (session_restore_strategy_ !=
1421 OAuth2LoginManager::RESTORE_FROM_COOKIE_JAR) { 1420 OAuth2LoginManager::RESTORE_FROM_COOKIE_JAR) {
1422 chrome::AttemptRestart(); 1421 chrome::AttemptRestart();
1423 return; 1422 return;
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1572 default_ime_states_.erase(profile); 1571 default_ime_states_.erase(profile);
1573 } 1572 }
1574 1573
1575 void UserSessionManager::InjectStubUserContext( 1574 void UserSessionManager::InjectStubUserContext(
1576 const UserContext& user_context) { 1575 const UserContext& user_context) {
1577 injected_user_context_.reset(new UserContext(user_context)); 1576 injected_user_context_.reset(new UserContext(user_context));
1578 authenticator_ = NULL; 1577 authenticator_ = NULL;
1579 } 1578 }
1580 1579
1581 } // namespace chromeos 1580 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698