Commit 9ddc9992 authored by Roman Sorokin's avatar Roman Sorokin Committed by Commit Bot

Chromad: Do not force online signin on TGT problems

Now users are blocked on online signin when authpolicyd failed to get
kerberos credentials

BUG=chromium:824204
TEST=AuthPolicyCredentialsManagerTest.*

Change-Id: Iae490a5615842aaae356e29501667453d86cd11c
Reviewed-on: https://chromium-review.googlesource.com/983917
Commit-Queue: Roman Sorokin <rsorokin@chromium.org>
Reviewed-by: default avatarLutz Justen <ljusten@chromium.org>
Reviewed-by: default avatarAlexander Alekseev <alemate@chromium.org>
Cr-Commit-Position: refs/heads/master@{#547687}
parent 6434d5e9
...@@ -202,28 +202,28 @@ void AuthPolicyCredentialsManager::OnGetUserStatusCallback( ...@@ -202,28 +202,28 @@ void AuthPolicyCredentialsManager::OnGetUserStatusCallback(
UpdateDisplayAndGivenName(user_status.account_info()); UpdateDisplayAndGivenName(user_status.account_info());
} }
// user_status.password_status() is missing if the TGT is invalid. // user_status.password_status() is missing if the TGT is invalid or device is
bool password_ok = false; // offline.
bool force_online_signin = false;
if (user_status.has_password_status()) { if (user_status.has_password_status()) {
switch (user_status.password_status()) { switch (user_status.password_status()) {
case authpolicy::ActiveDirectoryUserStatus::PASSWORD_VALID: case authpolicy::ActiveDirectoryUserStatus::PASSWORD_VALID:
password_ok = true;
break; break;
case authpolicy::ActiveDirectoryUserStatus::PASSWORD_EXPIRED: case authpolicy::ActiveDirectoryUserStatus::PASSWORD_EXPIRED:
ShowNotification(IDS_ACTIVE_DIRECTORY_PASSWORD_EXPIRED); ShowNotification(IDS_ACTIVE_DIRECTORY_PASSWORD_EXPIRED);
force_online_signin = true;
break; break;
case authpolicy::ActiveDirectoryUserStatus::PASSWORD_CHANGED: case authpolicy::ActiveDirectoryUserStatus::PASSWORD_CHANGED:
ShowNotification(IDS_ACTIVE_DIRECTORY_PASSWORD_CHANGED); ShowNotification(IDS_ACTIVE_DIRECTORY_PASSWORD_CHANGED);
force_online_signin = true;
break; break;
} }
} }
// user_status.tgt_status() is always present. // user_status.tgt_status() is always present.
bool tgt_ok = false;
DCHECK(user_status.has_tgt_status()); DCHECK(user_status.has_tgt_status());
switch (user_status.tgt_status()) { switch (user_status.tgt_status()) {
case authpolicy::ActiveDirectoryUserStatus::TGT_VALID: case authpolicy::ActiveDirectoryUserStatus::TGT_VALID:
tgt_ok = true;
break; break;
case authpolicy::ActiveDirectoryUserStatus::TGT_EXPIRED: case authpolicy::ActiveDirectoryUserStatus::TGT_EXPIRED:
case authpolicy::ActiveDirectoryUserStatus::TGT_NOT_FOUND: case authpolicy::ActiveDirectoryUserStatus::TGT_NOT_FOUND:
...@@ -231,8 +231,8 @@ void AuthPolicyCredentialsManager::OnGetUserStatusCallback( ...@@ -231,8 +231,8 @@ void AuthPolicyCredentialsManager::OnGetUserStatusCallback(
break; break;
} }
const bool ok = password_ok && tgt_ok; user_manager::UserManager::Get()->SaveForceOnlineSignin(account_id_,
user_manager::UserManager::Get()->SaveForceOnlineSignin(account_id_, !ok); force_online_signin);
} }
void AuthPolicyCredentialsManager::GetUserKerberosFiles() { void AuthPolicyCredentialsManager::GetUserKerberosFiles() {
......
...@@ -184,4 +184,24 @@ TEST_F(AuthPolicyCredentialsManagerTest, ShowDifferentNotifications) { ...@@ -184,4 +184,24 @@ TEST_F(AuthPolicyCredentialsManagerTest, ShowDifferentNotifications) {
EXPECT_EQ(0, GetNumberOfNotifications()); EXPECT_EQ(0, GetNumberOfNotifications());
} }
// Tests invalid TGT status does not force online signin but still shows
// a notification.
TEST_F(AuthPolicyCredentialsManagerTest, InvalidTGTDoesntForceOnlineSignin) {
fake_auth_policy_client()->set_tgt_status(
authpolicy::ActiveDirectoryUserStatus::TGT_EXPIRED);
EXPECT_CALL(*mock_user_manager(), SaveForceOnlineSignin(account_id(), false));
CallGetUserStatusAndWait();
EXPECT_EQ(1, GetNumberOfNotifications());
CancelNotificationById(IDS_ACTIVE_DIRECTORY_REFRESH_AUTH_TOKEN);
EXPECT_EQ(0, GetNumberOfNotifications());
}
// Tests successfull case does not show any notification and does not force
// online signin.
TEST_F(AuthPolicyCredentialsManagerTest, Success_NoNotifications) {
EXPECT_CALL(*mock_user_manager(), SaveForceOnlineSignin(account_id(), false));
CallGetUserStatusAndWait();
EXPECT_EQ(0, GetNumberOfNotifications());
}
} // namespace chromeos } // namespace chromeos
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