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 "chrome/browser/chromeos/login/saml/saml_offline_signin_limiter.h" | 5 #include "chrome/browser/chromeos/login/saml/saml_offline_signin_limiter.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 } | 38 } |
39 | 39 |
40 void SAMLOfflineSigninLimiter::SignedIn(UserContext::AuthFlow auth_flow) { | 40 void SAMLOfflineSigninLimiter::SignedIn(UserContext::AuthFlow auth_flow) { |
41 PrefService* prefs = profile_->GetPrefs(); | 41 PrefService* prefs = profile_->GetPrefs(); |
42 const user_manager::User* user = | 42 const user_manager::User* user = |
43 ProfileHelper::Get()->GetUserByProfile(profile_); | 43 ProfileHelper::Get()->GetUserByProfile(profile_); |
44 if (!user) { | 44 if (!user) { |
45 NOTREACHED(); | 45 NOTREACHED(); |
46 return; | 46 return; |
47 } | 47 } |
48 const std::string& user_id = user->email(); | 48 const AccountId account_id = user->GetAccountId(); |
49 | 49 |
50 if (auth_flow == UserContext::AUTH_FLOW_GAIA_WITHOUT_SAML) { | 50 if (auth_flow == UserContext::AUTH_FLOW_GAIA_WITHOUT_SAML) { |
51 // The user went through online authentication and GAIA did not redirect to | 51 // The user went through online authentication and GAIA did not redirect to |
52 // a SAML IdP. No limit applies in this case. Clear the time of last login | 52 // a SAML IdP. No limit applies in this case. Clear the time of last login |
53 // with SAML and the flag enforcing online login, then return. | 53 // with SAML and the flag enforcing online login, then return. |
54 prefs->ClearPref(prefs::kSAMLLastGAIASignInTime); | 54 prefs->ClearPref(prefs::kSAMLLastGAIASignInTime); |
55 user_manager::UserManager::Get()->SaveForceOnlineSignin(user_id, false); | 55 user_manager::UserManager::Get()->SaveForceOnlineSignin(account_id, false); |
56 return; | 56 return; |
57 } | 57 } |
58 | 58 |
59 if (auth_flow == UserContext::AUTH_FLOW_GAIA_WITH_SAML) { | 59 if (auth_flow == UserContext::AUTH_FLOW_GAIA_WITH_SAML) { |
60 // The user went through online authentication and GAIA did redirect to a | 60 // The user went through online authentication and GAIA did redirect to a |
61 // SAML IdP. Update the time of last login with SAML and clear the flag | 61 // SAML IdP. Update the time of last login with SAML and clear the flag |
62 // enforcing online login. The flag will be set again when the limit | 62 // enforcing online login. The flag will be set again when the limit |
63 // expires. If the limit already expired (e.g. because it was set to zero), | 63 // expires. If the limit already expired (e.g. because it was set to zero), |
64 // the flag will be set again immediately. | 64 // the flag will be set again immediately. |
65 user_manager::UserManager::Get()->SaveForceOnlineSignin(user_id, false); | 65 user_manager::UserManager::Get()->SaveForceOnlineSignin(account_id, false); |
66 prefs->SetInt64(prefs::kSAMLLastGAIASignInTime, | 66 prefs->SetInt64(prefs::kSAMLLastGAIASignInTime, |
67 clock_->Now().ToInternalValue()); | 67 clock_->Now().ToInternalValue()); |
68 } | 68 } |
69 | 69 |
70 // Start listening for pref changes. | 70 // Start listening for pref changes. |
71 pref_change_registrar_.Init(prefs); | 71 pref_change_registrar_.Init(prefs); |
72 pref_change_registrar_.Add(prefs::kSAMLOfflineSigninTimeLimit, | 72 pref_change_registrar_.Add(prefs::kSAMLOfflineSigninTimeLimit, |
73 base::Bind(&SAMLOfflineSigninLimiter::UpdateLimit, | 73 base::Bind(&SAMLOfflineSigninLimiter::UpdateLimit, |
74 base::Unretained(this))); | 74 base::Unretained(this))); |
75 | 75 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 } | 136 } |
137 | 137 |
138 void SAMLOfflineSigninLimiter::ForceOnlineLogin() { | 138 void SAMLOfflineSigninLimiter::ForceOnlineLogin() { |
139 const user_manager::User* user = | 139 const user_manager::User* user = |
140 ProfileHelper::Get()->GetUserByProfile(profile_); | 140 ProfileHelper::Get()->GetUserByProfile(profile_); |
141 if (!user) { | 141 if (!user) { |
142 NOTREACHED(); | 142 NOTREACHED(); |
143 return; | 143 return; |
144 } | 144 } |
145 | 145 |
146 user_manager::UserManager::Get()->SaveForceOnlineSignin(user->email(), true); | 146 user_manager::UserManager::Get()->SaveForceOnlineSignin(user->GetAccountId(), |
147 RecordReauthReason(user->email(), ReauthReason::SAML_REAUTH_POLICY); | 147 true); |
| 148 RecordReauthReason(user->GetAccountId(), ReauthReason::SAML_REAUTH_POLICY); |
148 offline_signin_limit_timer_.reset(); | 149 offline_signin_limit_timer_.reset(); |
149 } | 150 } |
150 | 151 |
151 } // namespace chromeos | 152 } // namespace chromeos |
OLD | NEW |