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

Side by Side Diff: chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.cc

Issue 148843002: Make an online wildcard login check for enterprise devices. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Filter out well-known consumer domains. Created 6 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/policy/user_cloud_policy_manager_chromeos.h" 5 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "base/metrics/sparse_histogram.h" 11 #include "base/metrics/sparse_histogram.h"
12 #include "base/sequenced_task_runner.h" 12 #include "base/sequenced_task_runner.h"
13 #include "chrome/browser/browser_process.h" 13 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/chromeos/policy/policy_oauth2_token_fetcher.h" 14 #include "chrome/browser/chromeos/policy/policy_oauth2_token_fetcher.h"
15 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom eos.h" 15 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom eos.h"
16 #include "chrome/browser/chromeos/policy/wildcard_login_checker.h"
16 #include "chrome/browser/chromeos/profiles/profile_helper.h" 17 #include "chrome/browser/chromeos/profiles/profile_helper.h"
18 #include "chrome/browser/lifetime/application_lifetime.h"
17 #include "components/policy/core/common/cloud/cloud_external_data_manager.h" 19 #include "components/policy/core/common/cloud/cloud_external_data_manager.h"
18 #include "components/policy/core/common/cloud/cloud_policy_refresh_scheduler.h" 20 #include "components/policy/core/common/cloud/cloud_policy_refresh_scheduler.h"
19 #include "components/policy/core/common/cloud/device_management_service.h" 21 #include "components/policy/core/common/cloud/device_management_service.h"
20 #include "components/policy/core/common/cloud/system_policy_request_context.h" 22 #include "components/policy/core/common/cloud/system_policy_request_context.h"
21 #include "components/policy/core/common/policy_pref_names.h" 23 #include "components/policy/core/common/policy_pref_names.h"
22 #include "content/public/common/content_client.h" 24 #include "content/public/common/content_client.h"
23 #include "net/url_request/url_request_context_getter.h" 25 #include "net/url_request/url_request_context_getter.h"
24 #include "url/gurl.h" 26 #include "url/gurl.h"
25 27
26 namespace em = enterprise_management; 28 namespace em = enterprise_management;
(...skipping 13 matching lines...) Expand all
40 "Enterprise.UserPolicyChromeOS.InitialFetch.DelayOAuth2Token"; 42 "Enterprise.UserPolicyChromeOS.InitialFetch.DelayOAuth2Token";
41 const char kUMAInitialFetchDelayPolicyFetch[] = 43 const char kUMAInitialFetchDelayPolicyFetch[] =
42 "Enterprise.UserPolicyChromeOS.InitialFetch.DelayPolicyFetch"; 44 "Enterprise.UserPolicyChromeOS.InitialFetch.DelayPolicyFetch";
43 const char kUMAInitialFetchDelayTotal[] = 45 const char kUMAInitialFetchDelayTotal[] =
44 "Enterprise.UserPolicyChromeOS.InitialFetch.DelayTotal"; 46 "Enterprise.UserPolicyChromeOS.InitialFetch.DelayTotal";
45 const char kUMAInitialFetchOAuth2Error[] = 47 const char kUMAInitialFetchOAuth2Error[] =
46 "Enterprise.UserPolicyChromeOS.InitialFetch.OAuth2Error"; 48 "Enterprise.UserPolicyChromeOS.InitialFetch.OAuth2Error";
47 const char kUMAInitialFetchOAuth2NetworkError[] = 49 const char kUMAInitialFetchOAuth2NetworkError[] =
48 "Enterprise.UserPolicyChromeOS.InitialFetch.OAuth2NetworkError"; 50 "Enterprise.UserPolicyChromeOS.InitialFetch.OAuth2NetworkError";
49 51
52 void OnWildcardCheckCompleted(const std::string& username, bool result) {
53 if (!result) {
54 LOG(ERROR) << "Online wildcard login check failed, terminating session.";
55
56 // TODO(mnissler): This only removes the user pod from the login screen, but
57 // the cryptohome remains. This is because deleting the cryptohome for a
58 // logged-in session is not possible. Fix this either by delaying the
59 // cryptohome deletion operation or by getting rid of the in-session
60 // wildcard check.
61 chromeos::UserManager::Get()->RemoveUserFromList(username);
62 chrome::AttemptUserExit();
63 }
64 }
65
50 } // namespace 66 } // namespace
51 67
52 UserCloudPolicyManagerChromeOS::UserCloudPolicyManagerChromeOS( 68 UserCloudPolicyManagerChromeOS::UserCloudPolicyManagerChromeOS(
53 scoped_ptr<CloudPolicyStore> store, 69 scoped_ptr<CloudPolicyStore> store,
54 scoped_ptr<CloudExternalDataManager> external_data_manager, 70 scoped_ptr<CloudExternalDataManager> external_data_manager,
55 const base::FilePath& component_policy_cache_path, 71 const base::FilePath& component_policy_cache_path,
56 bool wait_for_policy_fetch, 72 bool wait_for_policy_fetch,
57 base::TimeDelta initial_policy_fetch_timeout, 73 base::TimeDelta initial_policy_fetch_timeout,
58 const scoped_refptr<base::SequencedTaskRunner>& task_runner, 74 const scoped_refptr<base::SequencedTaskRunner>& task_runner,
59 const scoped_refptr<base::SequencedTaskRunner>& file_task_runner, 75 const scoped_refptr<base::SequencedTaskRunner>& file_task_runner,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 if (service()->IsInitializationComplete()) { 134 if (service()->IsInitializationComplete()) {
119 OnInitializationCompleted(service()); 135 OnInitializationCompleted(service());
120 } else { 136 } else {
121 service()->AddObserver(this); 137 service()->AddObserver(this);
122 } 138 }
123 } 139 }
124 140
125 void UserCloudPolicyManagerChromeOS::OnAccessTokenAvailable( 141 void UserCloudPolicyManagerChromeOS::OnAccessTokenAvailable(
126 const std::string& access_token) { 142 const std::string& access_token) {
127 access_token_ = access_token; 143 access_token_ = access_token;
144
145 if (!wildcard_username_.empty()) {
146 (new WildcardLoginChecker())->StartWithAccessToken(
147 access_token,
148 base::Bind(&OnWildcardCheckCompleted, wildcard_username_));
149 }
150
128 if (service() && service()->IsInitializationComplete() && 151 if (service() && service()->IsInitializationComplete() &&
129 client() && !client()->is_registered()) { 152 client() && !client()->is_registered()) {
130 OnOAuth2PolicyTokenFetched( 153 OnOAuth2PolicyTokenFetched(
131 access_token, GoogleServiceAuthError(GoogleServiceAuthError::NONE)); 154 access_token, GoogleServiceAuthError(GoogleServiceAuthError::NONE));
132 } 155 }
133 } 156 }
134 157
135 bool UserCloudPolicyManagerChromeOS::IsClientRegistered() const { 158 bool UserCloudPolicyManagerChromeOS::IsClientRegistered() const {
136 return client() && client()->is_registered(); 159 return client() && client()->is_registered();
137 } 160 }
138 161
162 void UserCloudPolicyManagerChromeOS::EnableWildcardLoginCheck(
163 const std::string& username) {
164 wildcard_username_ = username;
165 }
166
139 void UserCloudPolicyManagerChromeOS::Shutdown() { 167 void UserCloudPolicyManagerChromeOS::Shutdown() {
140 if (client()) 168 if (client())
141 client()->RemoveObserver(this); 169 client()->RemoveObserver(this);
142 if (service()) 170 if (service())
143 service()->RemoveObserver(this); 171 service()->RemoveObserver(this);
144 token_fetcher_.reset(); 172 token_fetcher_.reset();
145 external_data_manager_->Disconnect(); 173 external_data_manager_->Disconnect();
146 CloudPolicyManager::Shutdown(); 174 CloudPolicyManager::Shutdown();
147 } 175 }
148 176
(...skipping 25 matching lines...) Expand all
174 // 202 //
175 // If |wait_for_policy_fetch_| is false then the UserCloudPolicyTokenForwarder 203 // If |wait_for_policy_fetch_| is false then the UserCloudPolicyTokenForwarder
176 // service will eventually call OnAccessTokenAvailable() once an access token 204 // service will eventually call OnAccessTokenAvailable() once an access token
177 // is available. That call may have already happened while waiting for 205 // is available. That call may have already happened while waiting for
178 // initialization of the CloudPolicyService, so in that case check if an 206 // initialization of the CloudPolicyService, so in that case check if an
179 // access token is already available. 207 // access token is already available.
180 if (!client()->is_registered()) { 208 if (!client()->is_registered()) {
181 if (wait_for_policy_fetch_) { 209 if (wait_for_policy_fetch_) {
182 FetchPolicyOAuthTokenUsingSigninProfile(); 210 FetchPolicyOAuthTokenUsingSigninProfile();
183 } else if (!access_token_.empty()) { 211 } else if (!access_token_.empty()) {
184 OnOAuth2PolicyTokenFetched( 212 OnAccessTokenAvailable(access_token_);
185 access_token_, GoogleServiceAuthError(GoogleServiceAuthError::NONE));
186 } 213 }
187 } 214 }
188 215
189 if (!wait_for_policy_fetch_) { 216 if (!wait_for_policy_fetch_) {
190 // If this isn't blocking on a policy fetch then 217 // If this isn't blocking on a policy fetch then
191 // CloudPolicyManager::OnStoreLoaded() already published the cached policy. 218 // CloudPolicyManager::OnStoreLoaded() already published the cached policy.
192 // Start the refresh scheduler now, which will eventually refresh the 219 // Start the refresh scheduler now, which will eventually refresh the
193 // cached policy or make the first fetch once the OAuth2 token is 220 // cached policy or make the first fetch once the OAuth2 token is
194 // available. 221 // available.
195 StartRefreshSchedulerIfReady(); 222 StartRefreshSchedulerIfReady();
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 g_browser_process->system_request_context(), 287 g_browser_process->system_request_context(),
261 base::Bind(&UserCloudPolicyManagerChromeOS::OnOAuth2PolicyTokenFetched, 288 base::Bind(&UserCloudPolicyManagerChromeOS::OnOAuth2PolicyTokenFetched,
262 base::Unretained(this)))); 289 base::Unretained(this))));
263 token_fetcher_->Start(); 290 token_fetcher_->Start();
264 } 291 }
265 292
266 void UserCloudPolicyManagerChromeOS::OnOAuth2PolicyTokenFetched( 293 void UserCloudPolicyManagerChromeOS::OnOAuth2PolicyTokenFetched(
267 const std::string& policy_token, 294 const std::string& policy_token,
268 const GoogleServiceAuthError& error) { 295 const GoogleServiceAuthError& error) {
269 DCHECK(!client()->is_registered()); 296 DCHECK(!client()->is_registered());
270
271 time_token_available_ = base::Time::Now(); 297 time_token_available_ = base::Time::Now();
272 if (wait_for_policy_fetch_) { 298 if (wait_for_policy_fetch_) {
273 UMA_HISTOGRAM_MEDIUM_TIMES(kUMAInitialFetchDelayOAuth2Token, 299 UMA_HISTOGRAM_MEDIUM_TIMES(kUMAInitialFetchDelayOAuth2Token,
274 time_token_available_ - time_init_completed_); 300 time_token_available_ - time_init_completed_);
275 } 301 }
276 302
277 if (error.state() == GoogleServiceAuthError::NONE) { 303 if (error.state() == GoogleServiceAuthError::NONE) {
278 // Start client registration. Either OnRegistrationStateChanged() or 304 // Start client registration. Either OnRegistrationStateChanged() or
279 // OnClientError() will be called back. 305 // OnClientError() will be called back.
280 client()->Register(em::DeviceRegisterRequest::USER, 306 client()->Register(em::DeviceRegisterRequest::USER,
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 // OnComponentCloudPolicyUpdated() once it's ready. 368 // OnComponentCloudPolicyUpdated() once it's ready.
343 return; 369 return;
344 } 370 }
345 371
346 core()->StartRefreshScheduler(); 372 core()->StartRefreshScheduler();
347 core()->TrackRefreshDelayPref(local_state_, 373 core()->TrackRefreshDelayPref(local_state_,
348 policy_prefs::kUserPolicyRefreshRate); 374 policy_prefs::kUserPolicyRefreshRate);
349 } 375 }
350 376
351 } // namespace policy 377 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698