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

Unified Diff: chrome/browser/chromeos/enrollment_dialog_view.cc

Issue 2828713002: Enable client certificate patterns in device ONC policy (Closed)
Patch Set: Addressed comments. Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/enrollment_dialog_view.cc
diff --git a/chrome/browser/chromeos/enrollment_dialog_view.cc b/chrome/browser/chromeos/enrollment_dialog_view.cc
index 33f3af5a4bfdb2e073d95eb3517c9a7d5c812f09..96f342fc65dbbe2e39750acafeb0c5b4857f1690 100644
--- a/chrome/browser/chromeos/enrollment_dialog_view.cc
+++ b/chrome/browser/chromeos/enrollment_dialog_view.cc
@@ -16,6 +16,7 @@
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/browser_navigator_params.h"
#include "chrome/grit/generated_resources.h"
+#include "chromeos/login/login_state.h"
#include "chromeos/network/client_cert_util.h"
#include "chromeos/network/managed_network_configuration_handler.h"
#include "chromeos/network/network_event_log.h"
@@ -251,6 +252,37 @@ void EnrollmentComplete(const std::string& network_id) {
NET_LOG_USER("Enrollment Complete", network_id);
}
+// Decides if the enrollment dialog is allowed in the current login state.
+bool EnrollmentDialogAllowed() {
+ chromeos::LoginState::LoggedInUserType user_type =
+ LoginState::Get()->GetLoggedInUserType();
+ switch (user_type) {
+ case LoginState::LOGGED_IN_USER_NONE:
+ // Enrollment on the sign-in screen would not work anyway because we have
+ // no extensions there yet and no PKCS11 token is loaded.
emaxx 2017/04/25 15:15:58 nit: The part "because we have no extensions there
pmarko 2017/04/25 16:59:57 Done. (You're right - I've dropped the comments he
+ return false;
+ case LoginState::LOGGED_IN_USER_REGULAR:
+ return true;
emaxx 2017/04/25 15:15:58 I'm afraid this potentially opens the possibility
pmarko 2017/04/25 16:59:57 Done. (Added back IsSigninProfile check in the beg
+ case LoginState::LOGGED_IN_USER_OWNER:
+ return true;
+ case LoginState::LOGGED_IN_USER_GUEST:
+ return true;
+ case LoginState::LOGGED_IN_USER_PUBLIC_ACCOUNT:
+ // Not allowed for now because we haven't tested this.
emaxx 2017/04/25 15:15:58 nit: I think it's better not to track in the code
pmarko 2017/04/25 16:59:57 Done.
+ return false;
+ case LoginState::LOGGED_IN_USER_SUPERVISED:
+ return true;
+ case LoginState::LOGGED_IN_USER_KIOSK_APP:
+ // We don't want to show dialogs on kiosk.
+ return false;
+ case LoginState::LOGGED_IN_USER_ARC_KIOSK_APP:
+ // We don't want to show dialogs on kiosk.
+ return false;
+ }
+ NOTREACHED();
+ return false;
+}
+
} // namespace
////////////////////////////////////////////////////////////////////////////////
@@ -270,6 +302,8 @@ bool CreateEnrollmentDialog(const std::string& network_id,
Browser* browser = chrome::FindBrowserWithWindow(owning_window);
Profile* profile =
browser ? browser->profile() : ProfileManager::GetPrimaryUserProfile();
+ if (!EnrollmentDialogAllowed())
+ return false;
std::string username_hash = ProfileHelper::GetUserIdHashFromProfile(profile);
onc::ONCSource onc_source = onc::ONC_SOURCE_NONE;
@@ -278,14 +312,11 @@ bool CreateEnrollmentDialog(const std::string& network_id,
->managed_network_configuration_handler()
->FindPolicyByGUID(username_hash, network_id, &onc_source);
- // We skip certificate patterns for device policy ONC so that an unmanaged
- // user can't get to the place where a cert is presented for them
- // involuntarily.
- if (!policy || onc_source == onc::ONC_SOURCE_DEVICE_POLICY)
+ if (!policy)
return false;
client_cert::ClientCertConfig cert_config;
- OncToClientCertConfig(*policy, &cert_config);
+ OncToClientCertConfig(onc_source, *policy, &cert_config);
if (cert_config.client_cert_type != onc::client_cert::kPattern)
return false;

Powered by Google App Engine
This is Rietveld 408576698