Commit 92db6b2c authored by tnagel's avatar tnagel Committed by Commit Bot

Improve determination of managed state in DeviceSettingsProvider

Use PolicyData::management_mode to determine whether the device has a
local owner and only fall back to DM token in case management_mode is
unset.  That way, the correct determination is guaranteed for both
cloud and Active Directory management.  (Currently, the code is not
broken because AD policy doesn't include a user name, but that might
change in the future.)

Also update the PolicyData::management_mode documentation to include
Active Directory.

BUG=722799

Review-Url: https://codereview.chromium.org/2902183002
Cr-Commit-Position: refs/heads/master@{#476239}
parent 2c935aff
...@@ -742,8 +742,18 @@ void DeviceSettingsProvider::UpdateValuesCache( ...@@ -742,8 +742,18 @@ void DeviceSettingsProvider::UpdateValuesCache(
TrustedStatus trusted_status) { TrustedStatus trusted_status) {
PrefValueMap new_values_cache; PrefValueMap new_values_cache;
// Determine whether device is managed. See PolicyData::management_mode docs
// for details.
bool managed = false;
if (policy_data.has_management_mode()) {
managed =
(policy_data.management_mode() == em::PolicyData::ENTERPRISE_MANAGED);
} else {
managed = policy_data.has_request_token();
}
// If the device is not managed, we set the device owner value. // If the device is not managed, we set the device owner value.
if (policy_data.has_username() && !policy_data.has_request_token()) if (policy_data.has_username() && !managed)
new_values_cache.SetString(kDeviceOwner, policy_data.username()); new_values_cache.SetString(kDeviceOwner, policy_data.username());
if (policy_data.has_service_account_identity()) { if (policy_data.has_service_account_identity()) {
......
...@@ -292,10 +292,13 @@ message PolicyData { ...@@ -292,10 +292,13 @@ message PolicyData {
// anything like that. // anything like that.
optional int64 timestamp = 2; optional int64 timestamp = 2;
// The DM token that was used by the client in the HTTP POST header // The DM token that was used by the client in the HTTP POST header for
// for authenticating the request. It is included here again so that // authenticating the request. It is included here again so that the client
// the client can verify that the response is meant for them (and not // can verify that the response is meant for them (and not issued by a replay
// issued by a replay or man-in-the-middle attack). // or man-in-the-middle attack).
// Note that the existence or non-existence of the DM token is not the correct
// way to determine whether the device is managed. Cf. |management_mode| below
// for details.
optional string request_token = 3; optional string request_token = 3;
// The serialized value of the actual policy protobuf. This can be // The serialized value of the actual policy protobuf. This can be
...@@ -370,8 +373,8 @@ message PolicyData { ...@@ -370,8 +373,8 @@ message PolicyData {
// The device is owned locally. The policies are set by the local owner of // The device is owned locally. The policies are set by the local owner of
// the device. // the device.
LOCAL_OWNER = 0; LOCAL_OWNER = 0;
// The device is enterprise-managed. The policies come from the enterprise // The device is enterprise-managed (either via DM server or through Active
// server. See the comment above for backward compatibility. // Directory). See the comment above for backward compatibility.
ENTERPRISE_MANAGED = 1; ENTERPRISE_MANAGED = 1;
// Obsolete. Don't use. // Obsolete. Don't use.
OBSOLETE_CONSUMER_MANAGED = 2; OBSOLETE_CONSUMER_MANAGED = 2;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment