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/login_performer.h" | 5 #include "chromeos/login/auth/login_performer.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
11 #include "base/metrics/user_metrics.h" | 11 #include "base/metrics/user_metrics.h" |
12 #include "base/metrics/user_metrics_action.h" | 12 #include "base/metrics/user_metrics_action.h" |
13 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "base/threading/thread_restrictions.h" | 15 #include "base/threading/thread_restrictions.h" |
16 #include "chromeos/dbus/dbus_thread_manager.h" | 16 #include "chromeos/dbus/dbus_thread_manager.h" |
17 #include "chromeos/dbus/session_manager_client.h" | 17 #include "chromeos/dbus/session_manager_client.h" |
18 #include "chromeos/login/user_names.h" | 18 #include "chromeos/login/user_names.h" |
19 #include "chromeos/login_event_recorder.h" | 19 #include "chromeos/login_event_recorder.h" |
20 #include "chromeos/settings/cros_settings_names.h" | 20 #include "chromeos/settings/cros_settings_names.h" |
21 #include "components/signin/core/account_id/account_id.h" | |
21 #include "google_apis/gaia/gaia_auth_util.h" | 22 #include "google_apis/gaia/gaia_auth_util.h" |
22 #include "net/cookies/cookie_monster.h" | 23 #include "net/cookies/cookie_monster.h" |
23 #include "net/cookies/cookie_store.h" | 24 #include "net/cookies/cookie_store.h" |
24 #include "net/url_request/url_request_context.h" | 25 #include "net/url_request/url_request_context.h" |
25 #include "net/url_request/url_request_context_getter.h" | 26 #include "net/url_request/url_request_context_getter.h" |
26 | 27 |
27 using base::UserMetricsAction; | 28 using base::UserMetricsAction; |
28 | 29 |
29 namespace chromeos { | 30 namespace chromeos { |
30 | 31 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
100 } else { | 101 } else { |
101 NOTREACHED(); | 102 NOTREACHED(); |
102 } | 103 } |
103 } | 104 } |
104 | 105 |
105 //////////////////////////////////////////////////////////////////////////////// | 106 //////////////////////////////////////////////////////////////////////////////// |
106 // LoginPerformer, public: | 107 // LoginPerformer, public: |
107 | 108 |
108 void LoginPerformer::NotifyWhitelistCheckFailure() { | 109 void LoginPerformer::NotifyWhitelistCheckFailure() { |
109 if (delegate_) | 110 if (delegate_) |
110 delegate_->WhiteListCheckFailed(user_context_.GetUserID()); | 111 delegate_->WhiteListCheckFailed(user_context_.GetUserID().GetUserEmail()); |
111 else | 112 else |
112 NOTREACHED(); | 113 NOTREACHED(); |
113 } | 114 } |
114 | 115 |
115 void LoginPerformer::PerformLogin(const UserContext& user_context, | 116 void LoginPerformer::PerformLogin(const UserContext& user_context, |
116 AuthorizationMode auth_mode) { | 117 AuthorizationMode auth_mode) { |
117 auth_mode_ = auth_mode; | 118 auth_mode_ = auth_mode; |
118 user_context_ = user_context; | 119 user_context_ = user_context; |
119 | 120 |
120 if (RunTrustedCheck(base::Bind(&LoginPerformer::DoPerformLogin, | 121 if (RunTrustedCheck(base::Bind(&LoginPerformer::DoPerformLogin, |
121 weak_factory_.GetWeakPtr(), | 122 weak_factory_.GetWeakPtr(), |
122 user_context_, | 123 user_context_, |
123 auth_mode))) { | 124 auth_mode))) { |
124 return; | 125 return; |
125 } | 126 } |
126 DoPerformLogin(user_context_, auth_mode); | 127 DoPerformLogin(user_context_, auth_mode); |
127 } | 128 } |
128 | 129 |
129 void LoginPerformer::DoPerformLogin(const UserContext& user_context, | 130 void LoginPerformer::DoPerformLogin(const UserContext& user_context, |
130 AuthorizationMode auth_mode) { | 131 AuthorizationMode auth_mode) { |
131 std::string email = gaia::CanonicalizeEmail(user_context.GetUserID()); | 132 std::string email = |
achuithb
2015/10/23 00:08:51
const, isn't this already canonicalized?
Alexander Alekseev
2015/10/23 09:11:24
No ;-(
| |
133 gaia::CanonicalizeEmail(user_context.GetUserID().GetUserEmail()); | |
132 bool wildcard_match = false; | 134 bool wildcard_match = false; |
133 | 135 |
134 if (!IsUserWhitelisted(email, &wildcard_match)) { | 136 if (!IsUserWhitelisted(email, &wildcard_match)) { |
135 NotifyWhitelistCheckFailure(); | 137 NotifyWhitelistCheckFailure(); |
136 return; | 138 return; |
137 } | 139 } |
138 | 140 |
139 if (user_context.GetAuthFlow() == UserContext::AUTH_FLOW_EASY_UNLOCK) | 141 if (user_context.GetAuthFlow() == UserContext::AUTH_FLOW_EASY_UNLOCK) |
140 SetupEasyUnlockUserFlow(user_context.GetUserID()); | 142 SetupEasyUnlockUserFlow(user_context.GetUserID().GetUserEmail()); |
141 | 143 |
142 switch (auth_mode_) { | 144 switch (auth_mode_) { |
143 case AUTH_MODE_EXTENSION: { | 145 case AUTH_MODE_EXTENSION: { |
144 RunOnlineWhitelistCheck( | 146 RunOnlineWhitelistCheck( |
145 email, wildcard_match, user_context.GetRefreshToken(), | 147 email, wildcard_match, user_context.GetRefreshToken(), |
146 base::Bind(&LoginPerformer::StartLoginCompletion, | 148 base::Bind(&LoginPerformer::StartLoginCompletion, |
147 weak_factory_.GetWeakPtr()), | 149 weak_factory_.GetWeakPtr()), |
148 base::Bind(&LoginPerformer::NotifyWhitelistCheckFailure, | 150 base::Bind(&LoginPerformer::NotifyWhitelistCheckFailure, |
149 weak_factory_.GetWeakPtr())); | 151 weak_factory_.GetWeakPtr())); |
150 break; | 152 break; |
151 } | 153 } |
152 case AUTH_MODE_INTERNAL: | 154 case AUTH_MODE_INTERNAL: |
153 StartAuthentication(); | 155 StartAuthentication(); |
154 break; | 156 break; |
155 } | 157 } |
156 } | 158 } |
157 | 159 |
158 void LoginPerformer::LoginAsSupervisedUser(const UserContext& user_context) { | 160 void LoginPerformer::LoginAsSupervisedUser(const UserContext& user_context) { |
159 DCHECK_EQ(chromeos::login::kSupervisedUserDomain, | 161 DCHECK_EQ(chromeos::login::kSupervisedUserDomain, |
160 gaia::ExtractDomainName(user_context.GetUserID())); | 162 gaia::ExtractDomainName(user_context.GetUserID().GetUserEmail())); |
161 | 163 |
162 user_context_ = user_context; | 164 user_context_ = user_context; |
163 user_context_.SetUserType(user_manager::USER_TYPE_SUPERVISED); | 165 user_context_.SetUserType(user_manager::USER_TYPE_SUPERVISED); |
164 | 166 |
165 if (RunTrustedCheck(base::Bind(&LoginPerformer::TrustedLoginAsSupervisedUser, | 167 if (RunTrustedCheck(base::Bind(&LoginPerformer::TrustedLoginAsSupervisedUser, |
166 weak_factory_.GetWeakPtr(), | 168 weak_factory_.GetWeakPtr(), |
167 user_context_))) { | 169 user_context_))) { |
168 return; | 170 return; |
169 } | 171 } |
170 TrustedLoginAsSupervisedUser(user_context_); | 172 TrustedLoginAsSupervisedUser(user_context_); |
171 } | 173 } |
172 | 174 |
173 void LoginPerformer::TrustedLoginAsSupervisedUser( | 175 void LoginPerformer::TrustedLoginAsSupervisedUser( |
174 const UserContext& user_context) { | 176 const UserContext& user_context) { |
175 if (!AreSupervisedUsersAllowed()) { | 177 if (!AreSupervisedUsersAllowed()) { |
176 LOG(ERROR) << "Login attempt of supervised user detected."; | 178 LOG(ERROR) << "Login attempt of supervised user detected."; |
177 delegate_->WhiteListCheckFailed(user_context.GetUserID()); | 179 delegate_->WhiteListCheckFailed(user_context.GetUserID().GetUserEmail()); |
178 return; | 180 return; |
179 } | 181 } |
180 | 182 |
181 SetupSupervisedUserFlow(user_context.GetUserID()); | 183 SetupSupervisedUserFlow(user_context.GetUserID().GetUserEmail()); |
182 UserContext user_context_copy = TransformSupervisedKey(user_context); | 184 UserContext user_context_copy = TransformSupervisedKey(user_context); |
183 | 185 |
184 if (UseExtendedAuthenticatorForSupervisedUser(user_context)) { | 186 if (UseExtendedAuthenticatorForSupervisedUser(user_context)) { |
185 EnsureExtendedAuthenticator(); | 187 EnsureExtendedAuthenticator(); |
186 // TODO(antrim) : Replace empty callback with explicit method. | 188 // TODO(antrim) : Replace empty callback with explicit method. |
187 // http://crbug.com/351268 | 189 // http://crbug.com/351268 |
188 task_runner_->PostTask( | 190 task_runner_->PostTask( |
189 FROM_HERE, | 191 FROM_HERE, |
190 base::Bind(&ExtendedAuthenticator::AuthenticateToMount, | 192 base::Bind(&ExtendedAuthenticator::AuthenticateToMount, |
191 extended_authenticator_.get(), | 193 extended_authenticator_.get(), |
192 user_context_copy, | 194 user_context_copy, |
193 ExtendedAuthenticator::ResultCallback())); | 195 ExtendedAuthenticator::ResultCallback())); |
194 | 196 |
195 } else { | 197 } else { |
196 EnsureAuthenticator(); | 198 EnsureAuthenticator(); |
197 task_runner_->PostTask(FROM_HERE, | 199 task_runner_->PostTask(FROM_HERE, |
198 base::Bind(&Authenticator::LoginAsSupervisedUser, | 200 base::Bind(&Authenticator::LoginAsSupervisedUser, |
199 authenticator_.get(), | 201 authenticator_.get(), |
200 user_context_copy)); | 202 user_context_copy)); |
201 } | 203 } |
202 } | 204 } |
203 | 205 |
204 void LoginPerformer::LoginAsPublicSession(const UserContext& user_context) { | 206 void LoginPerformer::LoginAsPublicSession(const UserContext& user_context) { |
205 if (!CheckPolicyForUser(user_context.GetUserID())) { | 207 if (!CheckPolicyForUser(user_context.GetUserID().GetUserEmail())) { |
206 DCHECK(delegate_); | 208 DCHECK(delegate_); |
207 if (delegate_) | 209 if (delegate_) |
208 delegate_->PolicyLoadFailed(); | 210 delegate_->PolicyLoadFailed(); |
209 return; | 211 return; |
210 } | 212 } |
211 | 213 |
212 EnsureAuthenticator(); | 214 EnsureAuthenticator(); |
213 task_runner_->PostTask(FROM_HERE, | 215 task_runner_->PostTask(FROM_HERE, |
214 base::Bind(&Authenticator::LoginAsPublicSession, | 216 base::Bind(&Authenticator::LoginAsPublicSession, |
215 authenticator_.get(), | 217 authenticator_.get(), |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
282 } else { | 284 } else { |
283 NOTREACHED(); | 285 NOTREACHED(); |
284 } | 286 } |
285 user_context_.ClearSecrets(); | 287 user_context_.ClearSecrets(); |
286 } | 288 } |
287 | 289 |
288 void LoginPerformer::EnsureAuthenticator() { | 290 void LoginPerformer::EnsureAuthenticator() { |
289 authenticator_ = CreateAuthenticator(); | 291 authenticator_ = CreateAuthenticator(); |
290 } | 292 } |
291 } // namespace chromeos | 293 } // namespace chromeos |
OLD | NEW |