OLD | NEW |
---|---|
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 "chromeos/login/auth/cryptohome_authenticator.h" | 5 #include "chromeos/login/auth/cryptohome_authenticator.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/location.h" | 13 #include "base/location.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "chromeos/chromeos_switches.h" | |
16 #include "chromeos/cryptohome/async_method_caller.h" | 17 #include "chromeos/cryptohome/async_method_caller.h" |
17 #include "chromeos/cryptohome/cryptohome_parameters.h" | 18 #include "chromeos/cryptohome/cryptohome_parameters.h" |
18 #include "chromeos/cryptohome/homedir_methods.h" | 19 #include "chromeos/cryptohome/homedir_methods.h" |
19 #include "chromeos/cryptohome/system_salt_getter.h" | 20 #include "chromeos/cryptohome/system_salt_getter.h" |
20 #include "chromeos/dbus/cryptohome_client.h" | 21 #include "chromeos/dbus/cryptohome_client.h" |
21 #include "chromeos/dbus/dbus_thread_manager.h" | 22 #include "chromeos/dbus/dbus_thread_manager.h" |
22 #include "chromeos/login/auth/auth_status_consumer.h" | 23 #include "chromeos/login/auth/auth_status_consumer.h" |
23 #include "chromeos/login/auth/key.h" | 24 #include "chromeos/login/auth/key.h" |
24 #include "chromeos/login/auth/user_context.h" | 25 #include "chromeos/login/auth/user_context.h" |
25 #include "chromeos/login/login_state.h" | 26 #include "chromeos/login/login_state.h" |
26 #include "chromeos/login/user_names.h" | 27 #include "chromeos/login/user_names.h" |
27 #include "chromeos/login_event_recorder.h" | 28 #include "chromeos/login_event_recorder.h" |
28 #include "components/device_event_log/device_event_log.h" | 29 #include "components/device_event_log/device_event_log.h" |
29 #include "components/signin/core/account_id/account_id.h" | 30 #include "components/signin/core/account_id/account_id.h" |
31 #include "components/user_manager/known_user.h" | |
30 #include "components/user_manager/user_type.h" | 32 #include "components/user_manager/user_type.h" |
31 #include "third_party/cros_system_api/dbus/service_constants.h" | 33 #include "third_party/cros_system_api/dbus/service_constants.h" |
32 | 34 |
33 namespace chromeos { | 35 namespace chromeos { |
34 | 36 |
35 namespace { | 37 namespace { |
36 | 38 |
37 // The label used for the key derived from the user's GAIA credentials. | 39 // The label used for the key derived from the user's GAIA credentials. |
38 const char kCryptohomeGAIAKeyLabel[] = "gaia"; | 40 const char kCryptohomeGAIAKeyLabel[] = "gaia"; |
39 | 41 |
40 // The name under which the type of key generated from the user's GAIA | 42 // The name under which the type of key generated from the user's GAIA |
41 // credentials is stored. | 43 // credentials is stored. |
42 const char kKeyProviderDataTypeName[] = "type"; | 44 const char kKeyProviderDataTypeName[] = "type"; |
43 | 45 |
44 // The name under which the salt used to generate a key from the user's GAIA | 46 // The name under which the salt used to generate a key from the user's GAIA |
45 // credentials is stored. | 47 // credentials is stored. |
46 const char kKeyProviderDataSaltName[] = "salt"; | 48 const char kKeyProviderDataSaltName[] = "salt"; |
47 | 49 |
50 // Subsystem name for GaiaId migration status. | |
51 const char kCryptohome[] = "cryptohome"; | |
52 | |
48 // Hashes |key| with |system_salt| if it its type is KEY_TYPE_PASSWORD_PLAIN. | 53 // Hashes |key| with |system_salt| if it its type is KEY_TYPE_PASSWORD_PLAIN. |
49 // Returns the keys unmodified otherwise. | 54 // Returns the keys unmodified otherwise. |
50 scoped_ptr<Key> TransformKeyIfNeeded(const Key& key, | 55 scoped_ptr<Key> TransformKeyIfNeeded(const Key& key, |
51 const std::string& system_salt) { | 56 const std::string& system_salt) { |
52 scoped_ptr<Key> result(new Key(key)); | 57 scoped_ptr<Key> result(new Key(key)); |
53 if (result->GetKeyType() == Key::KEY_TYPE_PASSWORD_PLAIN) | 58 if (result->GetKeyType() == Key::KEY_TYPE_PASSWORD_PLAIN) |
54 result->Transform(Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, system_salt); | 59 result->Transform(Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, system_salt); |
55 | 60 |
56 return result; | 61 return result; |
57 } | 62 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
108 chromeos::LoginEventRecorder::Get()->AddLoginTimeMarker("CryptohomeMount-End", | 113 chromeos::LoginEventRecorder::Get()->AddLoginTimeMarker("CryptohomeMount-End", |
109 false); | 114 false); |
110 attempt->RecordCryptohomeStatus(success, return_code); | 115 attempt->RecordCryptohomeStatus(success, return_code); |
111 if (success) | 116 if (success) |
112 attempt->RecordUsernameHash(mount_hash); | 117 attempt->RecordUsernameHash(mount_hash); |
113 else | 118 else |
114 attempt->RecordUsernameHashFailed(); | 119 attempt->RecordUsernameHashFailed(); |
115 resolver->Resolve(); | 120 resolver->Resolve(); |
116 } | 121 } |
117 | 122 |
123 // Handle cryptohome migration status. | |
124 void OnCryptohomeRenamed(const AccountId& account_id, | |
125 const base::Closure& callback, | |
126 bool success, | |
127 cryptohome::MountError return_code) { | |
128 chromeos::LoginEventRecorder::Get()->AddLoginTimeMarker( | |
129 "CryptohomeRename-End", false); | |
130 if (success) { | |
131 user_manager::known_user::SetGaiaIdMigrationStatusDone(account_id, | |
132 kCryptohome); | |
133 } else { | |
134 LOG(ERROR) << "Failed to rename cryptohome for account_id={" | |
135 << account_id.Serialize() << "} (return_code=" << return_code | |
136 << ")"; | |
xiyuan
2016/02/17 23:14:26
What happens if we run into this? User sees a logi
Alexander Alekseev
2016/02/18 13:45:15
You're right. I've updated cryprohome::Identificat
| |
137 } | |
138 | |
139 callback.Run(); | |
140 } | |
141 | |
118 // Calls cryptohome's MountEx() method. The key in |attempt->user_context| must | 142 // Calls cryptohome's MountEx() method. The key in |attempt->user_context| must |
119 // not be a plain text password. If the user provided a plain text password, | 143 // not be a plain text password. If the user provided a plain text password, |
120 // that password must be transformed to another key type (by salted hashing) | 144 // that password must be transformed to another key type (by salted hashing) |
121 // before calling this method. | 145 // before calling this method. |
122 void DoMount(const base::WeakPtr<AuthAttemptState>& attempt, | 146 void DoMount(const base::WeakPtr<AuthAttemptState>& attempt, |
123 scoped_refptr<CryptohomeAuthenticator> resolver, | 147 scoped_refptr<CryptohomeAuthenticator> resolver, |
124 bool ephemeral, | 148 bool ephemeral, |
125 bool create_if_nonexistent) { | 149 bool create_if_nonexistent) { |
126 const Key* key = attempt->user_context.GetKey(); | 150 const Key* key = attempt->user_context.GetKey(); |
127 // If the |key| is a plain text password, crash rather than attempting to | 151 // If the |key| is a plain text password, crash rather than attempting to |
(...skipping 12 matching lines...) Expand all Loading... | |
140 const cryptohome::KeyDefinition auth_key(key->GetSecret(), | 164 const cryptohome::KeyDefinition auth_key(key->GetSecret(), |
141 std::string(), | 165 std::string(), |
142 cryptohome::PRIV_DEFAULT); | 166 cryptohome::PRIV_DEFAULT); |
143 cryptohome::MountParameters mount(ephemeral); | 167 cryptohome::MountParameters mount(ephemeral); |
144 if (create_if_nonexistent) { | 168 if (create_if_nonexistent) { |
145 mount.create_keys.push_back(cryptohome::KeyDefinition( | 169 mount.create_keys.push_back(cryptohome::KeyDefinition( |
146 key->GetSecret(), | 170 key->GetSecret(), |
147 kCryptohomeGAIAKeyLabel, | 171 kCryptohomeGAIAKeyLabel, |
148 cryptohome::PRIV_DEFAULT)); | 172 cryptohome::PRIV_DEFAULT)); |
149 } | 173 } |
150 | 174 const bool is_gaiaid_migration_started = switches::IsGaiaIdMigrationStarted(); |
151 cryptohome::HomedirMethods::GetInstance()->MountEx( | 175 const base::Closure do_call_mount_ex = base::Bind( |
152 cryptohome::Identification( | 176 &cryptohome::HomedirMethods::MountEx, |
153 attempt->user_context.GetAccountId().GetUserEmail()), | 177 base::Unretained(cryptohome::HomedirMethods::GetInstance()), |
178 cryptohome::Identification(attempt->user_context.GetAccountId()), | |
154 cryptohome::Authorization(auth_key), mount, | 179 cryptohome::Authorization(auth_key), mount, |
155 base::Bind(&OnMount, attempt, resolver)); | 180 base::Bind(&OnMount, attempt, resolver)); |
181 if (is_gaiaid_migration_started && !create_if_nonexistent && | |
182 !user_manager::known_user::GetGaiaIdMigrationStatus( | |
183 attempt->user_context.GetAccountId(), kCryptohome)) { | |
184 chromeos::LoginEventRecorder::Get()->AddLoginTimeMarker( | |
185 "CryptohomeRename-Start", false); | |
186 const std::string& cryptohome_id_from = | |
187 attempt->user_context.GetAccountId().GetUserEmail(); // Migrated | |
188 const std::string cryptohome_id_to = | |
189 attempt->user_context.GetAccountId().GetGaiaIdKey(); | |
xiyuan
2016/02/17 23:14:26
This looks like for the existing users. How can we
Alexander Alekseev
2016/02/18 13:45:15
You're right. I will also split migration from mou
| |
190 | |
191 cryptohome::HomedirMethods::GetInstance()->RenameCryptohome( | |
192 cryptohome::Identification::FromString(cryptohome_id_from), | |
193 cryptohome::Identification::FromString(cryptohome_id_to), | |
194 base::Bind(&OnCryptohomeRenamed, attempt->user_context.GetAccountId(), | |
195 do_call_mount_ex)); | |
196 } else { | |
197 // Mark new users migrated. | |
198 if (is_gaiaid_migration_started) { | |
199 user_manager::known_user::SetGaiaIdMigrationStatusDone( | |
200 attempt->user_context.GetAccountId(), kCryptohome); | |
201 } | |
202 do_call_mount_ex.Run(); | |
203 } | |
156 } | 204 } |
157 | 205 |
158 // Callback invoked when the system salt has been retrieved. Transforms the key | 206 // Callback invoked when the system salt has been retrieved. Transforms the key |
159 // in |attempt->user_context| using Chrome's default hashing algorithm and the | 207 // in |attempt->user_context| using Chrome's default hashing algorithm and the |
160 // system salt, then calls MountEx(). | 208 // system salt, then calls MountEx(). |
161 void OnGetSystemSalt(const base::WeakPtr<AuthAttemptState>& attempt, | 209 void OnGetSystemSalt(const base::WeakPtr<AuthAttemptState>& attempt, |
162 scoped_refptr<CryptohomeAuthenticator> resolver, | 210 scoped_refptr<CryptohomeAuthenticator> resolver, |
163 bool ephemeral, | 211 bool ephemeral, |
164 bool create_if_nonexistent, | 212 bool create_if_nonexistent, |
165 const std::string& system_salt) { | 213 const std::string& system_salt) { |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
260 chromeos::LoginEventRecorder::Get()->AddLoginTimeMarker( | 308 chromeos::LoginEventRecorder::Get()->AddLoginTimeMarker( |
261 "CryptohomeMount-Start", false); | 309 "CryptohomeMount-Start", false); |
262 | 310 |
263 if (attempt->user_context.GetKey()->GetKeyType() != | 311 if (attempt->user_context.GetKey()->GetKeyType() != |
264 Key::KEY_TYPE_PASSWORD_PLAIN) { | 312 Key::KEY_TYPE_PASSWORD_PLAIN) { |
265 DoMount(attempt, resolver, ephemeral, create_if_nonexistent); | 313 DoMount(attempt, resolver, ephemeral, create_if_nonexistent); |
266 return; | 314 return; |
267 } | 315 } |
268 | 316 |
269 cryptohome::HomedirMethods::GetInstance()->GetKeyDataEx( | 317 cryptohome::HomedirMethods::GetInstance()->GetKeyDataEx( |
270 cryptohome::Identification( | 318 cryptohome::Identification(attempt->user_context.GetAccountId()), |
271 attempt->user_context.GetAccountId().GetUserEmail()), | |
272 kCryptohomeGAIAKeyLabel, base::Bind(&OnGetKeyDataEx, attempt, resolver, | 319 kCryptohomeGAIAKeyLabel, base::Bind(&OnGetKeyDataEx, attempt, resolver, |
273 ephemeral, create_if_nonexistent)); | 320 ephemeral, create_if_nonexistent)); |
274 } | 321 } |
275 | 322 |
276 // Calls cryptohome's mount method for guest and also get the user hash from | 323 // Calls cryptohome's mount method for guest and also get the user hash from |
277 // cryptohome. | 324 // cryptohome. |
278 void MountGuestAndGetHash(const base::WeakPtr<AuthAttemptState>& attempt, | 325 void MountGuestAndGetHash(const base::WeakPtr<AuthAttemptState>& attempt, |
279 scoped_refptr<CryptohomeAuthenticator> resolver) { | 326 scoped_refptr<CryptohomeAuthenticator> resolver) { |
280 attempt->UsernameHashRequested(); | 327 attempt->UsernameHashRequested(); |
281 cryptohome::AsyncMethodCaller::GetInstance()->AsyncMountGuest( | 328 cryptohome::AsyncMethodCaller::GetInstance()->AsyncMountGuest( |
282 base::Bind(&TriggerResolveWithLoginTimeMarker, | 329 base::Bind(&TriggerResolveWithLoginTimeMarker, |
283 "CryptohomeMount-End", | 330 "CryptohomeMount-End", |
284 attempt, | 331 attempt, |
285 resolver)); | 332 resolver)); |
286 cryptohome::AsyncMethodCaller::GetInstance()->AsyncGetSanitizedUsername( | 333 cryptohome::AsyncMethodCaller::GetInstance()->AsyncGetSanitizedUsername( |
287 attempt->user_context.GetAccountId().GetUserEmail(), | 334 cryptohome::Identification(attempt->user_context.GetAccountId()), |
288 base::Bind(&TriggerResolveHash, attempt, resolver)); | 335 base::Bind(&TriggerResolveHash, attempt, resolver)); |
289 } | 336 } |
290 | 337 |
291 // Calls cryptohome's MountPublic method | 338 // Calls cryptohome's MountPublic method |
292 void MountPublic(const base::WeakPtr<AuthAttemptState>& attempt, | 339 void MountPublic(const base::WeakPtr<AuthAttemptState>& attempt, |
293 scoped_refptr<CryptohomeAuthenticator> resolver, | 340 scoped_refptr<CryptohomeAuthenticator> resolver, |
294 int flags) { | 341 int flags) { |
295 cryptohome::AsyncMethodCaller::GetInstance()->AsyncMountPublic( | 342 cryptohome::AsyncMethodCaller::GetInstance()->AsyncMountPublic( |
296 attempt->user_context.GetAccountId().GetUserEmail(), flags, | 343 cryptohome::Identification(attempt->user_context.GetAccountId()), flags, |
297 base::Bind(&TriggerResolveWithLoginTimeMarker, | 344 base::Bind(&TriggerResolveWithLoginTimeMarker, |
298 "CryptohomeMountPublic-End", attempt, resolver)); | 345 "CryptohomeMountPublic-End", attempt, resolver)); |
299 cryptohome::AsyncMethodCaller::GetInstance()->AsyncGetSanitizedUsername( | 346 cryptohome::AsyncMethodCaller::GetInstance()->AsyncGetSanitizedUsername( |
300 attempt->user_context.GetAccountId().GetUserEmail(), | 347 cryptohome::Identification(attempt->user_context.GetAccountId()), |
301 base::Bind(&TriggerResolveHash, attempt, resolver)); | 348 base::Bind(&TriggerResolveHash, attempt, resolver)); |
302 } | 349 } |
303 | 350 |
304 // Calls cryptohome's key migration method. | 351 // Calls cryptohome's key migration method. |
305 void Migrate(const base::WeakPtr<AuthAttemptState>& attempt, | 352 void Migrate(const base::WeakPtr<AuthAttemptState>& attempt, |
306 scoped_refptr<CryptohomeAuthenticator> resolver, | 353 scoped_refptr<CryptohomeAuthenticator> resolver, |
307 bool passing_old_hash, | 354 bool passing_old_hash, |
308 const std::string& old_password, | 355 const std::string& old_password, |
309 const std::string& system_salt) { | 356 const std::string& system_salt) { |
310 chromeos::LoginEventRecorder::Get()->AddLoginTimeMarker( | 357 chromeos::LoginEventRecorder::Get()->AddLoginTimeMarker( |
311 "CryptohomeMigrate-Start", false); | 358 "CryptohomeMigrate-Start", false); |
312 cryptohome::AsyncMethodCaller* caller = | 359 cryptohome::AsyncMethodCaller* caller = |
313 cryptohome::AsyncMethodCaller::GetInstance(); | 360 cryptohome::AsyncMethodCaller::GetInstance(); |
314 | 361 |
315 // TODO(bartfab): Retrieve the hashing algorithm and salt to use for |old_key| | 362 // TODO(bartfab): Retrieve the hashing algorithm and salt to use for |old_key| |
316 // from cryptohomed. | 363 // from cryptohomed. |
317 scoped_ptr<Key> old_key = | 364 scoped_ptr<Key> old_key = |
318 TransformKeyIfNeeded(Key(old_password), system_salt); | 365 TransformKeyIfNeeded(Key(old_password), system_salt); |
319 scoped_ptr<Key> new_key = | 366 scoped_ptr<Key> new_key = |
320 TransformKeyIfNeeded(*attempt->user_context.GetKey(), system_salt); | 367 TransformKeyIfNeeded(*attempt->user_context.GetKey(), system_salt); |
321 if (passing_old_hash) { | 368 if (passing_old_hash) { |
322 caller->AsyncMigrateKey( | 369 caller->AsyncMigrateKey( |
323 attempt->user_context.GetAccountId().GetUserEmail(), | 370 cryptohome::Identification(attempt->user_context.GetAccountId()), |
324 old_key->GetSecret(), new_key->GetSecret(), | 371 old_key->GetSecret(), new_key->GetSecret(), |
325 base::Bind(&TriggerResolveWithLoginTimeMarker, "CryptohomeMount-End", | 372 base::Bind(&TriggerResolveWithLoginTimeMarker, "CryptohomeMount-End", |
326 attempt, resolver)); | 373 attempt, resolver)); |
327 } else { | 374 } else { |
328 caller->AsyncMigrateKey( | 375 caller->AsyncMigrateKey( |
329 attempt->user_context.GetAccountId().GetUserEmail(), | 376 cryptohome::Identification(attempt->user_context.GetAccountId()), |
330 new_key->GetSecret(), old_key->GetSecret(), | 377 new_key->GetSecret(), old_key->GetSecret(), |
331 base::Bind(&TriggerResolveWithLoginTimeMarker, "CryptohomeMount-End", | 378 base::Bind(&TriggerResolveWithLoginTimeMarker, "CryptohomeMount-End", |
332 attempt, resolver)); | 379 attempt, resolver)); |
333 } | 380 } |
334 } | 381 } |
335 | 382 |
336 // Calls cryptohome's remove method. | 383 // Calls cryptohome's remove method. |
337 void Remove(const base::WeakPtr<AuthAttemptState>& attempt, | 384 void Remove(const base::WeakPtr<AuthAttemptState>& attempt, |
338 scoped_refptr<CryptohomeAuthenticator> resolver) { | 385 scoped_refptr<CryptohomeAuthenticator> resolver) { |
339 chromeos::LoginEventRecorder::Get()->AddLoginTimeMarker( | 386 chromeos::LoginEventRecorder::Get()->AddLoginTimeMarker( |
340 "CryptohomeRemove-Start", false); | 387 "CryptohomeRemove-Start", false); |
341 cryptohome::AsyncMethodCaller::GetInstance()->AsyncRemove( | 388 cryptohome::AsyncMethodCaller::GetInstance()->AsyncRemove( |
342 attempt->user_context.GetAccountId().GetUserEmail(), | 389 cryptohome::Identification(attempt->user_context.GetAccountId()), |
343 base::Bind(&TriggerResolveWithLoginTimeMarker, "CryptohomeRemove-End", | 390 base::Bind(&TriggerResolveWithLoginTimeMarker, "CryptohomeRemove-End", |
344 attempt, resolver)); | 391 attempt, resolver)); |
345 } | 392 } |
346 | 393 |
347 // Calls cryptohome's key check method. | 394 // Calls cryptohome's key check method. |
348 void CheckKey(const base::WeakPtr<AuthAttemptState>& attempt, | 395 void CheckKey(const base::WeakPtr<AuthAttemptState>& attempt, |
349 scoped_refptr<CryptohomeAuthenticator> resolver, | 396 scoped_refptr<CryptohomeAuthenticator> resolver, |
350 const std::string& system_salt) { | 397 const std::string& system_salt) { |
351 scoped_ptr<Key> key = | 398 scoped_ptr<Key> key = |
352 TransformKeyIfNeeded(*attempt->user_context.GetKey(), system_salt); | 399 TransformKeyIfNeeded(*attempt->user_context.GetKey(), system_salt); |
353 cryptohome::AsyncMethodCaller::GetInstance()->AsyncCheckKey( | 400 cryptohome::AsyncMethodCaller::GetInstance()->AsyncCheckKey( |
354 attempt->user_context.GetAccountId().GetUserEmail(), key->GetSecret(), | 401 cryptohome::Identification(attempt->user_context.GetAccountId()), |
355 base::Bind(&TriggerResolve, attempt, resolver)); | 402 key->GetSecret(), base::Bind(&TriggerResolve, attempt, resolver)); |
356 } | 403 } |
357 | 404 |
358 } // namespace | 405 } // namespace |
359 | 406 |
360 CryptohomeAuthenticator::CryptohomeAuthenticator( | 407 CryptohomeAuthenticator::CryptohomeAuthenticator( |
361 scoped_refptr<base::TaskRunner> task_runner, | 408 scoped_refptr<base::TaskRunner> task_runner, |
362 AuthStatusConsumer* consumer) | 409 AuthStatusConsumer* consumer) |
363 : Authenticator(consumer), | 410 : Authenticator(consumer), |
364 task_runner_(task_runner), | 411 task_runner_(task_runner), |
365 migrate_attempted_(false), | 412 migrate_attempted_(false), |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
440 false, // online_complete | 487 false, // online_complete |
441 false)); // user_is_new | 488 false)); // user_is_new |
442 remove_user_data_on_failure_ = false; | 489 remove_user_data_on_failure_ = false; |
443 StartMount(current_state_->AsWeakPtr(), | 490 StartMount(current_state_->AsWeakPtr(), |
444 scoped_refptr<CryptohomeAuthenticator>(this), | 491 scoped_refptr<CryptohomeAuthenticator>(this), |
445 false /* ephemeral */, false /* create_if_nonexistent */); | 492 false /* ephemeral */, false /* create_if_nonexistent */); |
446 } | 493 } |
447 | 494 |
448 void CryptohomeAuthenticator::LoginOffTheRecord() { | 495 void CryptohomeAuthenticator::LoginOffTheRecord() { |
449 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 496 DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
450 current_state_.reset( | 497 current_state_.reset(new AuthAttemptState( |
451 new AuthAttemptState(UserContext(user_manager::USER_TYPE_GUEST, | 498 UserContext(user_manager::USER_TYPE_GUEST, login::GuestAccountId()), |
452 login::GuestAccountId().GetUserEmail()), | 499 false, // unlock |
453 false, // unlock | 500 false, // online_complete |
454 false, // online_complete | 501 false)); // user_is_new |
455 false)); // user_is_new | |
456 remove_user_data_on_failure_ = false; | 502 remove_user_data_on_failure_ = false; |
457 ephemeral_mount_attempted_ = true; | 503 ephemeral_mount_attempted_ = true; |
458 MountGuestAndGetHash(current_state_->AsWeakPtr(), | 504 MountGuestAndGetHash(current_state_->AsWeakPtr(), |
459 scoped_refptr<CryptohomeAuthenticator>(this)); | 505 scoped_refptr<CryptohomeAuthenticator>(this)); |
460 } | 506 } |
461 | 507 |
462 void CryptohomeAuthenticator::LoginAsPublicSession( | 508 void CryptohomeAuthenticator::LoginAsPublicSession( |
463 const UserContext& user_context) { | 509 const UserContext& user_context) { |
464 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 510 DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
465 DCHECK_EQ(user_manager::USER_TYPE_PUBLIC_ACCOUNT, user_context.GetUserType()); | 511 DCHECK_EQ(user_manager::USER_TYPE_PUBLIC_ACCOUNT, user_context.GetUserType()); |
466 | 512 |
467 current_state_.reset( | 513 current_state_.reset( |
468 new AuthAttemptState(user_context, | 514 new AuthAttemptState(user_context, |
469 false, // unlock | 515 false, // unlock |
470 false, // online_complete | 516 false, // online_complete |
471 false)); // user_is_new | 517 false)); // user_is_new |
472 remove_user_data_on_failure_ = false; | 518 remove_user_data_on_failure_ = false; |
473 ephemeral_mount_attempted_ = true; | 519 ephemeral_mount_attempted_ = true; |
474 StartMount(current_state_->AsWeakPtr(), | 520 StartMount(current_state_->AsWeakPtr(), |
475 scoped_refptr<CryptohomeAuthenticator>(this), true /* ephemeral */, | 521 scoped_refptr<CryptohomeAuthenticator>(this), true /* ephemeral */, |
476 true /* create_if_nonexistent */); | 522 true /* create_if_nonexistent */); |
477 } | 523 } |
478 | 524 |
479 void CryptohomeAuthenticator::LoginAsKioskAccount( | 525 void CryptohomeAuthenticator::LoginAsKioskAccount( |
480 const std::string& app_user_id, | 526 const std::string& app_user_id, |
481 bool use_guest_mount) { | 527 bool use_guest_mount) { |
482 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 528 DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
483 | 529 |
484 const std::string user_id = | 530 const AccountId account_id = |
485 use_guest_mount ? login::GuestAccountId().GetUserEmail() : app_user_id; | 531 use_guest_mount |
532 ? login::GuestAccountId() | |
533 : AccountId::FromUserEmail(login::CanonicalizeUserID(app_user_id)); | |
xiyuan
2016/02/17 23:14:26
We should not call login::CanonicalizeUserID for k
Alexander Alekseev
2016/02/18 13:45:15
This has always happened in UserContext constructo
| |
486 current_state_.reset(new AuthAttemptState( | 534 current_state_.reset(new AuthAttemptState( |
487 UserContext(user_manager::USER_TYPE_KIOSK_APP, user_id), | 535 UserContext(user_manager::USER_TYPE_KIOSK_APP, account_id), |
488 false, // unlock | 536 false, // unlock |
489 false, // online_complete | 537 false, // online_complete |
490 false)); // user_is_new | 538 false)); // user_is_new |
491 | 539 |
492 remove_user_data_on_failure_ = true; | 540 remove_user_data_on_failure_ = true; |
493 if (!use_guest_mount) { | 541 if (!use_guest_mount) { |
494 MountPublic(current_state_->AsWeakPtr(), | 542 MountPublic(current_state_->AsWeakPtr(), |
495 scoped_refptr<CryptohomeAuthenticator>(this), | 543 scoped_refptr<CryptohomeAuthenticator>(this), |
496 cryptohome::CREATE_IF_MISSING); | 544 cryptohome::CREATE_IF_MISSING); |
497 } else { | 545 } else { |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
873 Resolve(); | 921 Resolve(); |
874 } | 922 } |
875 | 923 |
876 void CryptohomeAuthenticator::SetOwnerState(bool owner_check_finished, | 924 void CryptohomeAuthenticator::SetOwnerState(bool owner_check_finished, |
877 bool check_result) { | 925 bool check_result) { |
878 owner_is_verified_ = owner_check_finished; | 926 owner_is_verified_ = owner_check_finished; |
879 user_can_login_ = check_result; | 927 user_can_login_ = check_result; |
880 } | 928 } |
881 | 929 |
882 } // namespace chromeos | 930 } // namespace chromeos |
OLD | NEW |