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

Commit f33222a

Browse files
authored
[local_auth] Adds federated Windows support (#5776)
1 parent 4ed29be commit f33222a

21 files changed

+988
-5
lines changed

packages/local_auth/local_auth/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.1.0
2+
3+
* Adds Windows support.
4+
15
## 2.0.2
26

37
* Fixes library_private_types_in_public_api, sort_child_properties_last and use_key_in_widget_constructors

packages/local_auth/local_auth/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ the user.
88
On supported devices, this includes authentication with biometrics such as
99
fingerprint or facial recognition.
1010

11-
| | Android | iOS |
12-
|-------------|-----------|------|
13-
| **Support** | SDK 16+\* | 9.0+ |
11+
| | Android | iOS | Windows |
12+
|-------------|-----------|------|-------------|
13+
| **Support** | SDK 16+\* | 9.0+ | Windows 10+ |
1414

1515
## Usage
1616

@@ -90,6 +90,8 @@ final bool didAuthenticate = await auth.authenticate(
9090
options: const AuthenticationOptions(biometricOnly: true));
9191
```
9292

93+
*Note*: `biometricOnly` is not supported on Windows since the Windows implementation's underlying API (Windows Hello) doesn't support selecting the authentication method.
94+
9395
#### Dialogs
9496

9597
The plugin provides default dialogs for the following cases:
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
cmake_minimum_required(VERSION 3.14)
2+
project(example LANGUAGES CXX)
3+
4+
set(BINARY_NAME "example")
5+
6+
cmake_policy(SET CMP0063 NEW)
7+
8+
set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
9+
10+
# Configure build options.
11+
get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
12+
if(IS_MULTICONFIG)
13+
set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release"
14+
CACHE STRING "" FORCE)
15+
else()
16+
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
17+
set(CMAKE_BUILD_TYPE "Debug" CACHE
18+
STRING "Flutter build mode" FORCE)
19+
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
20+
"Debug" "Profile" "Release")
21+
endif()
22+
endif()
23+
24+
set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
25+
set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
26+
set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}")
27+
set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}")
28+
29+
# Use Unicode for all projects.
30+
add_definitions(-DUNICODE -D_UNICODE)
31+
32+
# Compilation settings that should be applied to most targets.
33+
function(APPLY_STANDARD_SETTINGS TARGET)
34+
target_compile_features(${TARGET} PUBLIC cxx_std_17)
35+
target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100")
36+
target_compile_options(${TARGET} PRIVATE /EHsc)
37+
target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0")
38+
target_compile_definitions(${TARGET} PRIVATE "$<$<CONFIG:Debug>:_DEBUG>")
39+
endfunction()
40+
41+
set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
42+
43+
# Flutter library and tool build rules.
44+
add_subdirectory(${FLUTTER_MANAGED_DIR})
45+
46+
# Application build
47+
add_subdirectory("runner")
48+
49+
# Generated plugin build rules, which manage building the plugins and adding
50+
# them to the application.
51+
include(flutter/generated_plugins.cmake)
52+
53+
54+
# === Installation ===
55+
# Support files are copied into place next to the executable, so that it can
56+
# run in place. This is done instead of making a separate bundle (as on Linux)
57+
# so that building and running from within Visual Studio will work.
58+
set(BUILD_BUNDLE_DIR "$<TARGET_FILE_DIR:${BINARY_NAME}>")
59+
# Make the "install" step default, as it's required to run.
60+
set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1)
61+
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
62+
set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
63+
endif()
64+
65+
set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
66+
set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}")
67+
68+
install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
69+
COMPONENT Runtime)
70+
71+
install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
72+
COMPONENT Runtime)
73+
74+
install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
75+
COMPONENT Runtime)
76+
77+
if(PLUGIN_BUNDLED_LIBRARIES)
78+
install(FILES "${PLUGIN_BUNDLED_LIBRARIES}"
79+
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
80+
COMPONENT Runtime)
81+
endif()
82+
83+
# Fully re-copy the assets directory on each build to avoid having stale files
84+
# from a previous install.
85+
set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
86+
install(CODE "
87+
file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
88+
" COMPONENT Runtime)
89+
install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
90+
DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
91+
92+
# Install the AOT library on non-Debug builds only.
93+
install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
94+
CONFIGURATIONS Profile;Release
95+
COMPONENT Runtime)
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
cmake_minimum_required(VERSION 3.14)
2+
3+
set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")
4+
5+
# Configuration provided via flutter tool.
6+
include(${EPHEMERAL_DIR}/generated_config.cmake)
7+
8+
# TODO: Move the rest of this into files in ephemeral. See
9+
# https://github.com/flutter/flutter/issues/57146.
10+
set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper")
11+
12+
# === Flutter Library ===
13+
set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll")
14+
15+
# Published to parent scope for install step.
16+
set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
17+
set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
18+
set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
19+
set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE)
20+
21+
list(APPEND FLUTTER_LIBRARY_HEADERS
22+
"flutter_export.h"
23+
"flutter_windows.h"
24+
"flutter_messenger.h"
25+
"flutter_plugin_registrar.h"
26+
"flutter_texture_registrar.h"
27+
)
28+
list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/")
29+
add_library(flutter INTERFACE)
30+
target_include_directories(flutter INTERFACE
31+
"${EPHEMERAL_DIR}"
32+
)
33+
target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib")
34+
add_dependencies(flutter flutter_assemble)
35+
36+
# === Wrapper ===
37+
list(APPEND CPP_WRAPPER_SOURCES_CORE
38+
"core_implementations.cc"
39+
"standard_codec.cc"
40+
)
41+
list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/")
42+
list(APPEND CPP_WRAPPER_SOURCES_PLUGIN
43+
"plugin_registrar.cc"
44+
)
45+
list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/")
46+
list(APPEND CPP_WRAPPER_SOURCES_APP
47+
"flutter_engine.cc"
48+
"flutter_view_controller.cc"
49+
)
50+
list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/")
51+
52+
# Wrapper sources needed for a plugin.
53+
add_library(flutter_wrapper_plugin STATIC
54+
${CPP_WRAPPER_SOURCES_CORE}
55+
${CPP_WRAPPER_SOURCES_PLUGIN}
56+
)
57+
apply_standard_settings(flutter_wrapper_plugin)
58+
set_target_properties(flutter_wrapper_plugin PROPERTIES
59+
POSITION_INDEPENDENT_CODE ON)
60+
set_target_properties(flutter_wrapper_plugin PROPERTIES
61+
CXX_VISIBILITY_PRESET hidden)
62+
target_link_libraries(flutter_wrapper_plugin PUBLIC flutter)
63+
target_include_directories(flutter_wrapper_plugin PUBLIC
64+
"${WRAPPER_ROOT}/include"
65+
)
66+
add_dependencies(flutter_wrapper_plugin flutter_assemble)
67+
68+
# Wrapper sources needed for the runner.
69+
add_library(flutter_wrapper_app STATIC
70+
${CPP_WRAPPER_SOURCES_CORE}
71+
${CPP_WRAPPER_SOURCES_APP}
72+
)
73+
apply_standard_settings(flutter_wrapper_app)
74+
target_link_libraries(flutter_wrapper_app PUBLIC flutter)
75+
target_include_directories(flutter_wrapper_app PUBLIC
76+
"${WRAPPER_ROOT}/include"
77+
)
78+
add_dependencies(flutter_wrapper_app flutter_assemble)
79+
80+
# === Flutter tool backend ===
81+
# _phony_ is a non-existent file to force this command to run every time,
82+
# since currently there's no way to get a full input/output list from the
83+
# flutter tool.
84+
set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_")
85+
set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE)
86+
add_custom_command(
87+
OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
88+
${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN}
89+
${CPP_WRAPPER_SOURCES_APP}
90+
${PHONY_OUTPUT}
91+
COMMAND ${CMAKE_COMMAND} -E env
92+
${FLUTTER_TOOL_ENVIRONMENT}
93+
"${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat"
94+
windows-x64 $<CONFIG>
95+
VERBATIM
96+
)
97+
add_custom_target(flutter_assemble DEPENDS
98+
"${FLUTTER_LIBRARY}"
99+
${FLUTTER_LIBRARY_HEADERS}
100+
${CPP_WRAPPER_SOURCES_CORE}
101+
${CPP_WRAPPER_SOURCES_PLUGIN}
102+
${CPP_WRAPPER_SOURCES_APP}
103+
)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#
2+
# Generated file, do not edit.
3+
#
4+
5+
list(APPEND FLUTTER_PLUGIN_LIST
6+
local_auth_windows
7+
)
8+
9+
list(APPEND FLUTTER_FFI_PLUGIN_LIST
10+
)
11+
12+
set(PLUGIN_BUNDLED_LIBRARIES)
13+
14+
foreach(plugin ${FLUTTER_PLUGIN_LIST})
15+
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin})
16+
target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
17+
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
18+
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
19+
endforeach(plugin)
20+
21+
foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
22+
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin})
23+
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
24+
endforeach(ffi_plugin)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
cmake_minimum_required(VERSION 3.14)
2+
project(runner LANGUAGES CXX)
3+
4+
add_executable(${BINARY_NAME} WIN32
5+
"flutter_window.cpp"
6+
"main.cpp"
7+
"utils.cpp"
8+
"win32_window.cpp"
9+
"${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
10+
"Runner.rc"
11+
"runner.exe.manifest"
12+
)
13+
apply_standard_settings(${BINARY_NAME})
14+
target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX")
15+
target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
16+
target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
17+
add_dependencies(${BINARY_NAME} flutter_assemble)
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
// Microsoft Visual C++ generated resource script.
2+
//
3+
#pragma code_page(65001)
4+
#include "resource.h"
5+
6+
#define APSTUDIO_READONLY_SYMBOLS
7+
/////////////////////////////////////////////////////////////////////////////
8+
//
9+
// Generated from the TEXTINCLUDE 2 resource.
10+
//
11+
#include "winres.h"
12+
13+
/////////////////////////////////////////////////////////////////////////////
14+
#undef APSTUDIO_READONLY_SYMBOLS
15+
16+
/////////////////////////////////////////////////////////////////////////////
17+
// English (United States) resources
18+
19+
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
20+
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
21+
22+
#ifdef APSTUDIO_INVOKED
23+
/////////////////////////////////////////////////////////////////////////////
24+
//
25+
// TEXTINCLUDE
26+
//
27+
28+
1 TEXTINCLUDE
29+
BEGIN
30+
"resource.h\0"
31+
END
32+
33+
2 TEXTINCLUDE
34+
BEGIN
35+
"#include ""winres.h""\r\n"
36+
"\0"
37+
END
38+
39+
3 TEXTINCLUDE
40+
BEGIN
41+
"\r\n"
42+
"\0"
43+
END
44+
45+
#endif // APSTUDIO_INVOKED
46+
47+
48+
/////////////////////////////////////////////////////////////////////////////
49+
//
50+
// Icon
51+
//
52+
53+
// Icon with lowest ID value placed first to ensure application icon
54+
// remains consistent on all systems.
55+
IDI_APP_ICON ICON "resources\\app_icon.ico"
56+
57+
58+
/////////////////////////////////////////////////////////////////////////////
59+
//
60+
// Version
61+
//
62+
63+
#ifdef FLUTTER_BUILD_NUMBER
64+
#define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER
65+
#else
66+
#define VERSION_AS_NUMBER 1,0,0
67+
#endif
68+
69+
#ifdef FLUTTER_BUILD_NAME
70+
#define VERSION_AS_STRING #FLUTTER_BUILD_NAME
71+
#else
72+
#define VERSION_AS_STRING "1.0.0"
73+
#endif
74+
75+
VS_VERSION_INFO VERSIONINFO
76+
FILEVERSION VERSION_AS_NUMBER
77+
PRODUCTVERSION VERSION_AS_NUMBER
78+
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
79+
#ifdef _DEBUG
80+
FILEFLAGS VS_FF_DEBUG
81+
#else
82+
FILEFLAGS 0x0L
83+
#endif
84+
FILEOS VOS__WINDOWS32
85+
FILETYPE VFT_APP
86+
FILESUBTYPE 0x0L
87+
BEGIN
88+
BLOCK "StringFileInfo"
89+
BEGIN
90+
BLOCK "040904e4"
91+
BEGIN
92+
VALUE "CompanyName", "io.flutter.plugins" "\0"
93+
VALUE "FileDescription", "example" "\0"
94+
VALUE "FileVersion", VERSION_AS_STRING "\0"
95+
VALUE "InternalName", "example" "\0"
96+
VALUE "LegalCopyright", "Copyright (C) 2022 io.flutter.plugins. All rights reserved." "\0"
97+
VALUE "OriginalFilename", "example.exe" "\0"
98+
VALUE "ProductName", "example" "\0"
99+
VALUE "ProductVersion", VERSION_AS_STRING "\0"
100+
END
101+
END
102+
BLOCK "VarFileInfo"
103+
BEGIN
104+
VALUE "Translation", 0x409, 1252
105+
END
106+
END
107+
108+
#endif // English (United States) resources
109+
/////////////////////////////////////////////////////////////////////////////
110+
111+
112+
113+
#ifndef APSTUDIO_INVOKED
114+
/////////////////////////////////////////////////////////////////////////////
115+
//
116+
// Generated from the TEXTINCLUDE 3 resource.
117+
//
118+
119+
120+
/////////////////////////////////////////////////////////////////////////////
121+
#endif // not APSTUDIO_INVOKED

0 commit comments

Comments
 (0)