Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

[local_auth] Windows support. #4806

Merged
merged 33 commits into from May 17, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
7ccd968
[local_auth] Windows support.
azchohfi Jan 27, 2022
3906da5
Merge branch 'main' into local_auth_windows
azchohfi Feb 17, 2022
70c341d
Merge branch 'main' into local_auth_windows
azchohfi Feb 23, 2022
c492f89
Merge branch 'main' into local_auth_windows
azchohfi Feb 24, 2022
c997ad8
Handling biometricOnly parameter.
azchohfi Feb 25, 2022
9cf0a1a
Merge branch 'main' into local_auth_windows
azchohfi Apr 7, 2022
975ca8d
Fixed readme
azchohfi Apr 7, 2022
3fcbca7
[local_auth] Fix version and readme.
azchohfi Apr 8, 2022
34afbf5
Merge branch 'main' into local_auth_windows
azchohfi Apr 15, 2022
835f5cc
[local_auth] Small fixes.
azchohfi Apr 15, 2022
9eaba3c
Small fix.
azchohfi Apr 15, 2022
22ec14c
Fixed tests.
azchohfi Apr 15, 2022
9349aab
Added local_auth_windows tests.
azchohfi Apr 15, 2022
1032693
PR Feedback.
azchohfi Apr 18, 2022
1659e49
Merge branch 'local_auth_windows' of https://github.com/azchohfi/plug…
azchohfi Apr 18, 2022
8c7a87b
Fixed tests.
azchohfi Apr 18, 2022
bf47529
Added more tests.
azchohfi Apr 18, 2022
8143983
Revert changes in local_auth.
azchohfi Apr 19, 2022
bcf105b
Merge branch 'main' into local_auth_windows
azchohfi Apr 25, 2022
a4f02f4
Merge branch 'main' into local_auth_windows
azchohfi Apr 26, 2022
7449a5c
Merge branch 'main' into local_auth_windows
azchohfi May 9, 2022
fb26c93
Merge branch 'main' into local_auth_windows
azchohfi May 10, 2022
e9ab4ef
[local_auth_windows] Fixed authors list.
azchohfi May 10, 2022
30f0958
[local_auth_windows] Fixed changelog.
azchohfi May 10, 2022
97e1ee9
[local_auth_windows] PR feedback.
azchohfi May 12, 2022
40aa9a2
Merge branch 'main' into local_auth_windows
azchohfi May 12, 2022
6813b7b
Fixed build
azchohfi May 13, 2022
47823c6
Fixed format.
azchohfi May 13, 2022
45ceb6e
Merge branch 'main' into local_auth_windows
azchohfi May 13, 2022
271a49e
Applied more PR feedback.
azchohfi May 13, 2022
e1e24a6
Added C++ comments.
azchohfi May 13, 2022
cabc43e
Small doc fixes.
azchohfi May 13, 2022
34a58de
Merge branch 'main' into local_auth_windows
azchohfi May 16, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions packages/local_auth/local_auth_windows/windows/local_auth.h
Expand Up @@ -25,14 +25,21 @@

namespace local_auth_windows {

// Abstract class that is used to determine whether a user
// has given consent to a particular action, and if the system
// supports asking this question.
class UserConsentVerifier {
azchohfi marked this conversation as resolved.
Show resolved Hide resolved
public:
UserConsentVerifier() {}
virtual ~UserConsentVerifier() = default;

// Abstract method that request the user's verification
// given the provided reason.
virtual winrt::Windows::Foundation::IAsyncOperation<
winrt::Windows::Security::Credentials::UI::UserConsentVerificationResult>
RequestVerificationForWindowAsync(std::wstring localized_reason) = 0;

// Abstract method that returns weather the system supports Windows Hello.
virtual winrt::Windows::Foundation::IAsyncOperation<
winrt::Windows::Security::Credentials::UI::
UserConsentVerifierAvailability>
Expand All @@ -47,7 +54,12 @@ class LocalAuthPlugin : public flutter::Plugin {
public:
static void RegisterWithRegistrar(flutter::PluginRegistrarWindows* registrar);

// Real implementation that creates a plugin instance that will create the
azchohfi marked this conversation as resolved.
Show resolved Hide resolved
// dialog and associate it with the HWND returned from the provided function
azchohfi marked this conversation as resolved.
Show resolved Hide resolved
LocalAuthPlugin(std::function<HWND()> window_provider);

// Creates a plugin instance with the given UserConsentVerifier instance.
// Exists for unit testing with mock implementations.
LocalAuthPlugin(std::unique_ptr<UserConsentVerifier> user_consent_verifier);
azchohfi marked this conversation as resolved.
Show resolved Hide resolved

// Called when a method is called on this plugin's channel from Dart.
azchohfi marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -60,11 +72,16 @@ class LocalAuthPlugin : public flutter::Plugin {
private:
std::unique_ptr<UserConsentVerifier> user_consent_verifier_;

// Starts authentication process
azchohfi marked this conversation as resolved.
Show resolved Hide resolved
winrt::fire_and_forget Authenticate(
const flutter::MethodCall<flutter::EncodableValue>& method_call,
std::unique_ptr<flutter::MethodResult<flutter::EncodableValue>> result);

// Returns enrolled biometric types available on device.
winrt::fire_and_forget GetEnrolledBiometrics(
std::unique_ptr<flutter::MethodResult<flutter::EncodableValue>> result);

// Returns whether the system supports Windows Hello.
winrt::fire_and_forget IsDeviceSupported(
std::unique_ptr<flutter::MethodResult<flutter::EncodableValue>> result);
};
Expand Down
Expand Up @@ -54,12 +54,16 @@ std::wstring Utf16FromUtf8(const std::string& utf8_string) {

namespace local_auth_windows {

// Real implementation of the UserConsentVerifier that
// calls the native Windows APIs to get the user's consent
class UserConsentVerifierImpl : public UserConsentVerifier {
public:
explicit UserConsentVerifierImpl(std::function<HWND()> window_provider)
: get_root_window_(std::move(window_provider)){};
virtual ~UserConsentVerifierImpl() = default;

// Calls the native Windows API to get the user's consent
// with the provided reason.
winrt::Windows::Foundation::IAsyncOperation<
winrt::Windows::Security::Credentials::UI::UserConsentVerificationResult>
RequestVerificationForWindowAsync(std::wstring localized_reason) override {
Expand All @@ -85,6 +89,7 @@ class UserConsentVerifierImpl : public UserConsentVerifier {
return consent_result;
}

// Calls the native Windows API to check for the Windows Hello availability
azchohfi marked this conversation as resolved.
Show resolved Hide resolved
winrt::Windows::Foundation::IAsyncOperation<
winrt::Windows::Security::Credentials::UI::
UserConsentVerifierAvailability>
Expand Down