Skip to content

Commit

Permalink
Add Local Authentication Dialog for re-auth session.
Browse files Browse the repository at this point in the history
- Implement LocalAuthenticationdRequestView and related Widget and Controller
- Add unittest
- Add pixeltest
- Add a button that can use the dialog with a debug view

Change-Id: I2301ca4eea6ad21cb07a7f22a94de3af9e2ba748
Bug: b:291811391
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4819967
Reviewed-by: Denis Kuznetsov <antrim@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Commit-Queue: Istvan Nagy <iscsi@google.com>
Cr-Commit-Position: refs/heads/main@{#1217272}
  • Loading branch information
Istvan Nagy authored and Chromium LUCI CQ committed Oct 30, 2023
1 parent 533025a commit 93bfdf5
Show file tree
Hide file tree
Showing 19 changed files with 1,570 additions and 3 deletions.
24 changes: 22 additions & 2 deletions ash/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,12 @@ component("ash") {
"login/ui/image_parser.h",
"login/ui/kiosk_app_default_message.cc",
"login/ui/kiosk_app_default_message.h",
"login/ui/local_authentication_request_controller_impl.cc",
"login/ui/local_authentication_request_controller_impl.h",
"login/ui/local_authentication_request_view.cc",
"login/ui/local_authentication_request_view.h",
"login/ui/local_authentication_request_widget.cc",
"login/ui/local_authentication_request_widget.h",
"login/ui/lock_contents_view.cc",
"login/ui/lock_contents_view.h",
"login/ui/lock_contents_view_constants.h",
Expand Down Expand Up @@ -2842,6 +2848,8 @@ component("ash") {
"//chromeos/ash/components/assistant:buildflags",
"//chromeos/ash/components/audio",
"//chromeos/ash/components/auth_panel",
"//chromeos/ash/components/cryptohome:cryptohome",
"//chromeos/ash/components/cryptohome:public",
"//chromeos/ash/components/dbus/audio",
"//chromeos/ash/components/dbus/biod",
"//chromeos/ash/components/dbus/dlcservice",
Expand All @@ -2860,6 +2868,7 @@ component("ash") {
"//chromeos/ash/components/dbus/typecd",
"//chromeos/ash/components/dbus/update_engine",
"//chromeos/ash/components/dbus/usb",
"//chromeos/ash/components/dbus/userdataauth:userdataauth",
"//chromeos/ash/components/early_prefs",
"//chromeos/ash/components/feature_usage",
"//chromeos/ash/components/fwupd",
Expand Down Expand Up @@ -3291,8 +3300,6 @@ test("ash_unittests") {
"lock_screen_action/lock_screen_note_display_state_handler_unittest.cc",
"lock_screen_action/lock_screen_note_launcher_unittest.cc",
"login/login_screen_controller_unittest.cc",
"login/mock_login_screen_client.cc",
"login/mock_login_screen_client.h",
"login/security_token_request_controller_unittest.cc",
"login/ui/access_code_input.cc",
"login/ui/access_code_input.h",
Expand All @@ -3305,6 +3312,7 @@ test("ash_unittests") {
"login/ui/fake_smart_lock_auth_factor_model.cc",
"login/ui/fake_smart_lock_auth_factor_model.h",
"login/ui/fingerprint_auth_factor_model_unittest.cc",
"login/ui/local_authentication_request_controller_impl_unittest.cc",
"login/ui/lock_contents_view_unittest.cc",
"login/ui/lock_screen_media_controls_view_unittest.cc",
"login/ui/lock_screen_media_view_unittest.cc",
Expand Down Expand Up @@ -3873,8 +3881,11 @@ test("ash_unittests") {
"//chromeos/ash/components/assistant:buildflags",
"//chromeos/ash/components/audio",
"//chromeos/ash/components/cryptohome",
"//chromeos/ash/components/cryptohome:cryptohome",
"//chromeos/ash/components/dbus:test_support",
"//chromeos/ash/components/dbus/audio",
"//chromeos/ash/components/dbus/cryptohome:cryptohome",
"//chromeos/ash/components/dbus/cryptohome:cryptohome_proto",
"//chromeos/ash/components/dbus/dlcservice",
"//chromeos/ash/components/dbus/dlcservice:dlcservice_proto",
"//chromeos/ash/components/dbus/fwupd",
Expand Down Expand Up @@ -4066,6 +4077,7 @@ test("ash_pixeltests") {
"glanceables/glanceables_pixeltest.cc",
"glanceables/tasks/glanceables_task_view_pixeltest.cc",
"in_session_auth/auth_dialog_contents_view_pixeltest.cc",
"login/ui/local_authentication_request_controller_impl_pixeltest.cc",
"shelf/login_shelf_view_pixeltest.cc",
"shelf/scrollable_shelf_view_pixeltest.cc",
"shelf/shelf_layout_manager_pixeltest.cc",
Expand Down Expand Up @@ -4115,14 +4127,20 @@ test("ash_pixeltests") {
"//ash/public/cpp:test_support",
"//base/test:test_support",
"//chromeos/ash/components/audio",
"//chromeos/ash/components/cryptohome:cryptohome",
"//chromeos/ash/components/dbus/audio",
"//chromeos/ash/components/dbus/cryptohome:cryptohome",
"//chromeos/ash/components/dbus/cryptohome:cryptohome_proto",
"//chromeos/ash/components/dbus/userdataauth",
"//chromeos/ash/services/assistant/public/cpp",
"//chromeos/ash/services/bluetooth_config:test_support",
"//chromeos/dbus/power:power",
"//chromeos/dbus/power:power_manager_proto",
"//chromeos/services/network_config/public/cpp:test_support",
"//components/user_education/common",
"//components/user_education/views",
"//components/user_manager",
"//components/user_manager:test_support",
"//components/viz/test:test_support",
"//google_apis/calendar:test_support",
"//mojo/core/embedder:embedder",
Expand Down Expand Up @@ -4291,6 +4309,8 @@ static_library("test_support") {
"lock_screen_action/test_lock_screen_action_background_controller.cc",
"lock_screen_action/test_lock_screen_action_background_controller.h",
"login/login_screen_test_api.cc",
"login/mock_login_screen_client.cc",
"login/mock_login_screen_client.h",
"login/ui/login_test_base.cc",
"login/ui/login_test_base.h",
"login/ui/login_test_utils.cc",
Expand Down
6 changes: 6 additions & 0 deletions ash/ash_strings.grd
Original file line number Diff line number Diff line change
Expand Up @@ -4800,6 +4800,12 @@ Some features are limited to increase battery life.
<message name="IDS_ASH_LOGIN_PIN_REQUEST_NEXT_NUMBER_PROMPT" desc="Accessible prompt read when next access code input field has been focused. Asks user to enter next piece of the access code.">
Next number
</message>
<message name="IDS_ASH_LOGIN_LOCAL_AUTHENTICATION_REQUEST_TITLE" desc="Title of the local authentication input dialog that allows the user to login during the reauthenticate session.">
Finish verifying your identity
</message>
<message name="IDS_ASH_LOGIN_LOCAL_AUTHENTICATION_REQUEST_DESCRIPTION" desc="Description shown on the local authentication input dialog. Explains local authentication credentials should be used to unlock the device.">
Enter device password for <ph name="EMAIL">$1<ex>john.doe@example.com</ex></ph>
</message>
<message name="IDS_ASH_LOGIN_SECURITY_TOKEN_REQUEST_DIALOG_TITLE" desc="Title of the PIN dialog to unlock the device with a smart card.">
Smart card PIN
</message>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5d68d9ee4e421920f0866383b06fb1fc6bbd6b3e
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ca2a3ba9a0c6a226f293dbb8943414468b65f553
1 change: 0 additions & 1 deletion ash/login/mock_login_screen_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "ash/public/cpp/login_screen_client.h"
#include "base/memory/raw_ptr.h"
#include "base/time/time.h"
#include "components/password_manager/core/browser/hash_password_manager.h"
#include "testing/gmock/include/gmock/gmock.h"

namespace ash {
Expand Down
57 changes: 57 additions & 0 deletions ash/login/ui/local_authentication_request_controller_impl.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ash/login/ui/local_authentication_request_controller_impl.h"

#include <string>
#include <utility>

#include "ash/login/ui/local_authentication_request_view.h"
#include "ash/login/ui/local_authentication_request_widget.h"
#include "ash/session/session_controller_impl.h"
#include "ash/shell.h"
#include "ash/strings/grit/ash_strings.h"
#include "base/check.h"
#include "base/functional/bind.h"
#include "base/task/single_thread_task_runner.h"
#include "chromeos/ash/components/login/auth/public/user_context.h"
#include "components/account_id/account_id.h"
#include "components/session_manager/session_manager_types.h"
#include "ui/base/l10n/l10n_util.h"

namespace ash {

LocalAuthenticationRequestControllerImpl::
LocalAuthenticationRequestControllerImpl() = default;

LocalAuthenticationRequestControllerImpl::
~LocalAuthenticationRequestControllerImpl() = default;

void LocalAuthenticationRequestControllerImpl::OnClose() {}

bool LocalAuthenticationRequestControllerImpl::ShowWidget(
OnLocalAuthenticationCompleted on_local_authentication_completed,
std::unique_ptr<UserContext> user_context) {
if (LocalAuthenticationRequestWidget::Get()) {
LOG(ERROR) << "LocalAuthenticationRequestWidget is already shown.";
return false;
}

const AccountId& account_id = user_context->GetAccountId();

const std::string& user_email = account_id.GetUserEmail();

const std::u16string desc = l10n_util::GetStringFUTF16(
IDS_ASH_LOGIN_LOCAL_AUTHENTICATION_REQUEST_DESCRIPTION,
base::UTF8ToUTF16(user_email));

LocalAuthenticationRequestWidget::Show(
std::move(on_local_authentication_completed),
l10n_util::GetStringUTF16(
IDS_ASH_LOGIN_LOCAL_AUTHENTICATION_REQUEST_TITLE),
desc, this, std::move(user_context));
return true;
}

} // namespace ash
47 changes: 47 additions & 0 deletions ash/login/ui/local_authentication_request_controller_impl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef ASH_LOGIN_UI_LOCAL_AUTHENTICATION_REQUEST_CONTROLLER_IMPL_H_
#define ASH_LOGIN_UI_LOCAL_AUTHENTICATION_REQUEST_CONTROLLER_IMPL_H_

#include <memory>

#include "ash/login/ui/local_authentication_request_view.h"
#include "ash/login/ui/local_authentication_request_widget.h"
#include "ash/public/cpp/login/local_authentication_request_controller.h"
#include "base/memory/weak_ptr.h"

namespace ash {

class UserContext;

// Implementation of LocalAuthenticationRequestController. It serves to finalize
// the re-auth session with local authentication.
class ASH_EXPORT LocalAuthenticationRequestControllerImpl
: public LocalAuthenticationRequestController,
public LocalAuthenticationRequestView::Delegate {
public:
LocalAuthenticationRequestControllerImpl();
LocalAuthenticationRequestControllerImpl(
const LocalAuthenticationRequestControllerImpl&) = delete;
LocalAuthenticationRequestControllerImpl& operator=(
const LocalAuthenticationRequestControllerImpl&) = delete;
~LocalAuthenticationRequestControllerImpl() override;

// LocalAuthenticationRequestView::Delegate:
void OnClose() override;

// LocalAuthenticationRequestController:
bool ShowWidget(
OnLocalAuthenticationCompleted on_local_authentication_completed,
std::unique_ptr<UserContext> user_context) override;

private:
base::WeakPtrFactory<LocalAuthenticationRequestControllerImpl> weak_factory_{
this};
};

} // namespace ash

#endif // ASH_LOGIN_UI_LOCAL_AUTHENTICATION_REQUEST_CONTROLLER_IMPL_H_

0 comments on commit 93bfdf5

Please sign in to comment.