Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Add Linux PAM local auth

Neeraj Guptaea2511a13fdc
diff --git a/.github/workflows/auth-build.yml b/.github/workflows/auth-build.yml
index 2e2ff19378..bbcaff525e 100644
--- a/.github/workflows/auth-build.yml
+++ b/.github/workflows/auth-build.yml
@@ -245,7 +245,7 @@ jobs:
- name: Install dependencies for Linux build
run: |
sudo apt-get update
- sudo apt-get install -y libsecret-1-dev libsodium-dev libfuse2 ninja-build libgtk-3-dev dpkg-dev pkg-config rpm patchelf libsqlite3-dev locate libayatana-appindicator3-dev libffi-dev libtiff5 xz-utils libarchive-tools libcurl4-openssl-dev
+ sudo apt-get install -y libsecret-1-dev libsodium-dev libfuse2 ninja-build libgtk-3-dev libpam0g-dev dpkg-dev pkg-config rpm patchelf libsqlite3-dev locate libayatana-appindicator3-dev libffi-dev libtiff5 xz-utils libarchive-tools libcurl4-openssl-dev
sudo updatedb --localpaths='/usr/lib/x86_64-linux-gnu'
- name: Install fpm for RPM packaging
diff --git a/.github/workflows/mobile-packages-lint.yml b/.github/workflows/mobile-packages-lint.yml
index 386f20c204..e6406e88bb 100644
--- a/.github/workflows/mobile-packages-lint.yml
+++ b/.github/workflows/mobile-packages-lint.yml
@@ -155,6 +155,11 @@ jobs:
run: flutter pub get --enforce-lockfile && dart format --output=none --set-exit-if-changed . && flutter analyze --no-fatal-infos
working-directory: mobile/packages/legacy
+ - name: Lint package - local_auth_linux
+ if: needs.detect-changes.outputs.lint_all == 'true' || contains(needs.detect-changes.outputs.packages, 'local_auth_linux')
+ run: flutter pub get --enforce-lockfile && dart format --output=none --set-exit-if-changed . && flutter analyze --no-fatal-infos && flutter test
+ working-directory: mobile/packages/local_auth_linux
+
- name: Lint package - lock_screen
if: needs.detect-changes.outputs.lint_all == 'true' || contains(needs.detect-changes.outputs.packages, 'lock_screen')
run: flutter pub get --enforce-lockfile && dart format --output=none --set-exit-if-changed . && flutter analyze --no-fatal-infos
diff --git a/mobile/apps/auth/ios/Podfile.lock b/mobile/apps/auth/ios/Podfile.lock
index eee3ad29d0..3a2ed2d0cb 100644
--- a/mobile/apps/auth/ios/Podfile.lock
+++ b/mobile/apps/auth/ios/Podfile.lock
@@ -53,8 +53,6 @@ PODS:
- Flutter (1.0.0)
- flutter_email_sender (0.0.1):
- Flutter
- - flutter_local_authentication (1.2.0):
- - Flutter
- flutter_local_notifications (0.0.1):
- Flutter
- flutter_native_splash (2.4.3):
@@ -139,7 +137,6 @@ DEPENDENCIES:
- fk_user_agent (from `.symlinks/plugins/fk_user_agent/ios`)
- Flutter (from `Flutter`)
- flutter_email_sender (from `.symlinks/plugins/flutter_email_sender/ios`)
- - flutter_local_authentication (from `.symlinks/plugins/flutter_local_authentication/ios`)
- flutter_local_notifications (from `.symlinks/plugins/flutter_local_notifications/ios`)
- flutter_native_splash (from `.symlinks/plugins/flutter_native_splash/ios`)
- flutter_secure_storage (from `.symlinks/plugins/flutter_secure_storage/ios`)
@@ -193,8 +190,6 @@ EXTERNAL SOURCES:
:path: Flutter
flutter_email_sender:
:path: ".symlinks/plugins/flutter_email_sender/ios"
- flutter_local_authentication:
- :path: ".symlinks/plugins/flutter_local_authentication/ios"
flutter_local_notifications:
:path: ".symlinks/plugins/flutter_local_notifications/ios"
flutter_native_splash:
@@ -248,13 +243,12 @@ SPEC CHECKSUMS:
fk_user_agent: 137145b086229251761678fe034da53753f4ce59
Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467
flutter_email_sender: aa1e9772696691d02cd91fea829856c11efb8e58
- flutter_local_authentication: 989278c681612f1ee0e36019e149137f114b9d7f
flutter_local_notifications: 395056b3175ba4f08480a7c5de30cd36d69827e4
flutter_native_splash: c32d145d68aeda5502d5f543ee38c192065986cf
flutter_secure_storage: 2c2ff13db9e0a5647389bff88b0ecac56e3f3418
fluttertoast: 2c67e14dce98bbdb200df9e1acf610d7a6264ea1
launcher_icon_switcher: 84c218d233505aa7d8655d8fa61a3ba802c022da
- local_auth_darwin: d2e8c53ef0c4f43c646462e3415432c4dab3ae19
+ local_auth_darwin: c3ee6cce0a8d56be34c8ccb66ba31f7f180aaebb
move_to_background: 7e3467dd2a1d1013e98c9c1cb93fd53cd7ef9d84
MTBBarcodeScanner: f453b33c4b7dfe545d8c6484ed744d55671788cb
package_info_plus: af8e2ca6888548050f16fa2f1938db7b5a5df499
diff --git a/mobile/apps/auth/linux/flutter/generated_plugin_registrant.cc b/mobile/apps/auth/linux/flutter/generated_plugin_registrant.cc
index 6ca7ca2339..cbdd2b4fe6 100644
--- a/mobile/apps/auth/linux/flutter/generated_plugin_registrant.cc
+++ b/mobile/apps/auth/linux/flutter/generated_plugin_registrant.cc
@@ -7,9 +7,9 @@
#include "generated_plugin_registrant.h"
#include <file_saver/file_saver_plugin.h>
-#include <flutter_local_authentication/flutter_local_authentication_plugin.h>
#include <flutter_secure_storage_linux/flutter_secure_storage_linux_plugin.h>
#include <gtk/gtk_plugin.h>
+#include <local_auth_linux/local_auth_linux_plugin.h>
#include <screen_retriever_linux/screen_retriever_linux_plugin.h>
#include <sentry_flutter/sentry_flutter_plugin.h>
#include <sodium_libs/sodium_libs_plugin.h>
@@ -22,15 +22,15 @@ void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) file_saver_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "FileSaverPlugin");
file_saver_plugin_register_with_registrar(file_saver_registrar);
- g_autoptr(FlPluginRegistrar) flutter_local_authentication_registrar =
- fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterLocalAuthenticationPlugin");
- flutter_local_authentication_plugin_register_with_registrar(flutter_local_authentication_registrar);
g_autoptr(FlPluginRegistrar) flutter_secure_storage_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterSecureStorageLinuxPlugin");
flutter_secure_storage_linux_plugin_register_with_registrar(flutter_secure_storage_linux_registrar);
g_autoptr(FlPluginRegistrar) gtk_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "GtkPlugin");
gtk_plugin_register_with_registrar(gtk_registrar);
+ g_autoptr(FlPluginRegistrar) local_auth_linux_registrar =
+ fl_plugin_registry_get_registrar_for_plugin(registry, "LocalAuthLinuxPlugin");
+ local_auth_linux_plugin_register_with_registrar(local_auth_linux_registrar);
g_autoptr(FlPluginRegistrar) screen_retriever_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenRetrieverLinuxPlugin");
screen_retriever_linux_plugin_register_with_registrar(screen_retriever_linux_registrar);
diff --git a/mobile/apps/auth/linux/flutter/generated_plugins.cmake b/mobile/apps/auth/linux/flutter/generated_plugins.cmake
index d97d4ee844..20d25bcbf3 100644
--- a/mobile/apps/auth/linux/flutter/generated_plugins.cmake
+++ b/mobile/apps/auth/linux/flutter/generated_plugins.cmake
@@ -4,9 +4,9 @@
list(APPEND FLUTTER_PLUGIN_LIST
file_saver
- flutter_local_authentication
flutter_secure_storage_linux
gtk
+ local_auth_linux
screen_retriever_linux
sentry_flutter
sodium_libs
diff --git a/mobile/apps/auth/linux/packaging/build_rpm.sh b/mobile/apps/auth/linux/packaging/build_rpm.sh
index fcdb08eb15..515bf56d00 100755
--- a/mobile/apps/auth/linux/packaging/build_rpm.sh
+++ b/mobile/apps/auth/linux/packaging/build_rpm.sh
@@ -97,6 +97,7 @@ fpm -s dir -t rpm \
--depends sqlite-libs \
--depends libsecret \
--depends libappindicator \
+ --depends pam \
-C "$STAGING_DIR" \
-p "$OUTPUT_DIR/enteauth-VERSION.ARCH.rpm" \
.
diff --git a/mobile/apps/auth/linux/packaging/deb/make_config.yaml b/mobile/apps/auth/linux/packaging/deb/make_config.yaml
index 93b579f178..d368274009 100644
--- a/mobile/apps/auth/linux/packaging/deb/make_config.yaml
+++ b/mobile/apps/auth/linux/packaging/deb/make_config.yaml
@@ -18,6 +18,7 @@ dependencies:
- libsqlite3-0
- libsodium23
- libsecret-1-0
+ - libpam0g
- libappindicator3-1 | libayatana-appindicator3-1
- gir1.2-appindicator3-0.1 | gir1.2-ayatanaappindicator3-0.1
- libayatana-ido3-0.4-0
diff --git a/mobile/apps/auth/linux/packaging/pacman/make_config.yaml b/mobile/apps/auth/linux/packaging/pacman/make_config.yaml
index 5e4985f2cc..4c120ef519 100644
--- a/mobile/apps/auth/linux/packaging/pacman/make_config.yaml
+++ b/mobile/apps/auth/linux/packaging/pacman/make_config.yaml
@@ -14,6 +14,7 @@ dependencies:
- sqlite
- libsecret
- libappindicator-gtk3
+ - pam
keywords:
- Authentication
diff --git a/mobile/apps/auth/linux/packaging/rpm/make_config.yaml b/mobile/apps/auth/linux/packaging/rpm/make_config.yaml
index cbd7d14869..c3e1a39ea1 100644
--- a/mobile/apps/auth/linux/packaging/rpm/make_config.yaml
+++ b/mobile/apps/auth/linux/packaging/rpm/make_config.yaml
@@ -17,6 +17,7 @@ requires:
- libsqlite3x
- libsecret
- libappindicator
+ - pam
keywords:
- Authentication
diff --git a/mobile/apps/auth/macos/Flutter/GeneratedPluginRegistrant.swift b/mobile/apps/auth/macos/Flutter/GeneratedPluginRegistrant.swift
index ce9f300f2a..baf45d8c49 100644
--- a/mobile/apps/auth/macos/Flutter/GeneratedPluginRegistrant.swift
+++ b/mobile/apps/auth/macos/Flutter/GeneratedPluginRegistrant.swift
@@ -10,7 +10,6 @@ import connectivity_plus
import device_info_plus
import file_picker
import file_saver
-import flutter_local_authentication
import flutter_local_notifications
import flutter_secure_storage_macos
import local_auth_darwin
@@ -33,7 +32,6 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
FilePickerPlugin.register(with: registry.registrar(forPlugin: "FilePickerPlugin"))
FileSaverPlugin.register(with: registry.registrar(forPlugin: "FileSaverPlugin"))
- FlutterLocalAuthenticationPlugin.register(with: registry.registrar(forPlugin: "FlutterLocalAuthenticationPlugin"))
FlutterLocalNotificationsPlugin.register(with: registry.registrar(forPlugin: "FlutterLocalNotificationsPlugin"))
FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin"))
LocalAuthPlugin.register(with: registry.registrar(forPlugin: "LocalAuthPlugin"))
diff --git a/mobile/apps/auth/macos/Podfile.lock b/mobile/apps/auth/macos/Podfile.lock
index 28abe0aeb4..7cc258de26 100644
--- a/mobile/apps/auth/macos/Podfile.lock
+++ b/mobile/apps/auth/macos/Podfile.lock
@@ -12,8 +12,6 @@ PODS:
- FlutterMacOS
- file_saver (0.0.1):
- FlutterMacOS
- - flutter_local_authentication (1.2.0):
- - FlutterMacOS
- flutter_local_notifications (0.0.1):
- FlutterMacOS
- flutter_secure_storage_macos (6.1.3):
@@ -80,7 +78,6 @@ DEPENDENCIES:
- device_info_plus (from `Flutter/ephemeral/.symlinks/plugins/device_info_plus/macos`)
- file_picker (from `Flutter/ephemeral/.symlinks/plugins/file_picker/macos`)
- file_saver (from `Flutter/ephemeral/.symlinks/plugins/file_saver/macos`)
- - flutter_local_authentication (from `Flutter/ephemeral/.symlinks/plugins/flutter_local_authentication/macos`)
- flutter_local_notifications (from `Flutter/ephemeral/.symlinks/plugins/flutter_local_notifications/macos`)
- flutter_secure_storage_macos (from `Flutter/ephemeral/.symlinks/plugins/flutter_secure_storage_macos/macos`)
- FlutterMacOS (from `Flutter/ephemeral`)
@@ -116,8 +113,6 @@ EXTERNAL SOURCES:
:path: Flutter/ephemeral/.symlinks/plugins/file_picker/macos
file_saver:
:path: Flutter/ephemeral/.symlinks/plugins/file_saver/macos
- flutter_local_authentication:
- :path: Flutter/ephemeral/.symlinks/plugins/flutter_local_authentication/macos
flutter_local_notifications:
:path: Flutter/ephemeral/.symlinks/plugins/flutter_local_notifications/macos
flutter_secure_storage_macos:
@@ -158,11 +153,10 @@ SPEC CHECKSUMS:
device_info_plus: 4fb280989f669696856f8b129e4a5e3cd6c48f76
file_picker: 7584aae6fa07a041af2b36a2655122d42f578c1a
file_saver: e35bd97de451dde55ff8c38862ed7ad0f3418d0f
- flutter_local_authentication: 2f9a2682f498abcc12d7e9729b5007a947170fdc
flutter_local_notifications: 13862b132e32eb858dea558a86d45d08daeacfe7
flutter_secure_storage_macos: 7f45e30f838cf2659862a4e4e3ee1c347c2b3b54
FlutterMacOS: d0db08ddef1a9af05a5ec4b724367152bb0500b1
- local_auth_darwin: d2e8c53ef0c4f43c646462e3415432c4dab3ae19
+ local_auth_darwin: c3ee6cce0a8d56be34c8ccb66ba31f7f180aaebb
package_info_plus: f0052d280d17aa382b932f399edf32507174e870
scoped_dir_access: da65241007b6c91d1da6e757b1af9086b283c228
screen_retriever_macos: 452e51764a9e1cdb74b3c541238795849f21557f
diff --git a/mobile/apps/auth/pubspec.lock b/mobile/apps/auth/pubspec.lock
index 1fd40b1fde..287332144e 100644
--- a/mobile/apps/auth/pubspec.lock
+++ b/mobile/apps/auth/pubspec.lock
@@ -649,15 +649,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.14.4"
- flutter_local_authentication:
- dependency: "direct main"
- description:
- path: "."
- ref: "1ac346a04592a05fd75acccf2e01fa3c7e955d96"
- resolved-ref: "1ac346a04592a05fd75acccf2e01fa3c7e955d96"
- url: "https://github.com/eaceto/flutter_local_authentication"
- source: git
- version: "1.2.0"
flutter_local_notifications:
dependency: "direct main"
description:
@@ -1057,6 +1048,13 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.3"
+ local_auth_linux:
+ dependency: transitive
+ description:
+ path: "../../packages/local_auth_linux"
+ relative: true
+ source: path
+ version: "0.1.0"
local_auth_platform_interface:
dependency: transitive
description:
diff --git a/mobile/apps/auth/pubspec.yaml b/mobile/apps/auth/pubspec.yaml
index 6bee9c7777..48e9e05eca 100644
--- a/mobile/apps/auth/pubspec.yaml
+++ b/mobile/apps/auth/pubspec.yaml
@@ -73,10 +73,6 @@ dependencies:
flutter_displaymode: 0.6.0
flutter_email_sender: 7.0.0
flutter_launcher_icons: 0.14.4
- flutter_local_authentication: # linux fprintd fix is not published on pub.dev
- git:
- url: https://github.com/eaceto/flutter_local_authentication
- ref: 1ac346a04592a05fd75acccf2e01fa3c7e955d96
flutter_local_notifications: 18.0.1
flutter_localizations:
sdk: flutter
diff --git a/mobile/apps/auth/windows/flutter/generated_plugin_registrant.cc b/mobile/apps/auth/windows/flutter/generated_plugin_registrant.cc
index b3886728c0..1d9f219d44 100644
--- a/mobile/apps/auth/windows/flutter/generated_plugin_registrant.cc
+++ b/mobile/apps/auth/windows/flutter/generated_plugin_registrant.cc
@@ -9,7 +9,6 @@
#include <app_links/app_links_plugin_c_api.h>
#include <connectivity_plus/connectivity_plus_windows_plugin.h>
#include <file_saver/file_saver_plugin.h>
-#include <flutter_local_authentication/flutter_local_authentication_plugin_c_api.h>
#include <flutter_secure_storage_windows/flutter_secure_storage_windows_plugin.h>
#include <local_auth_windows/local_auth_plugin.h>
#include <screen_retriever_windows/screen_retriever_windows_plugin_c_api.h>
@@ -28,8 +27,6 @@ void RegisterPlugins(flutter::PluginRegistry* registry) {
registry->GetRegistrarForPlugin("ConnectivityPlusWindowsPlugin"));
FileSaverPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FileSaverPlugin"));
- FlutterLocalAuthenticationPluginCApiRegisterWithRegistrar(
- registry->GetRegistrarForPlugin("FlutterLocalAuthenticationPluginCApi"));
FlutterSecureStorageWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FlutterSecureStorageWindowsPlugin"));
LocalAuthPluginRegisterWithRegistrar(
diff --git a/mobile/apps/auth/windows/flutter/generated_plugins.cmake b/mobile/apps/auth/windows/flutter/generated_plugins.cmake
index 0bfde9e754..a4fbdd3aad 100644
--- a/mobile/apps/auth/windows/flutter/generated_plugins.cmake
+++ b/mobile/apps/auth/windows/flutter/generated_plugins.cmake
@@ -6,7 +6,6 @@ list(APPEND FLUTTER_PLUGIN_LIST
app_links
connectivity_plus
file_saver
- flutter_local_authentication
flutter_secure_storage_windows
local_auth_windows
screen_retriever_windows
diff --git a/mobile/apps/auth/windows/signing/allowed-pe-files.txt b/mobile/apps/auth/windows/signing/allowed-pe-files.txt
index 515c0bdf25..d282ad135e 100644
--- a/mobile/apps/auth/windows/signing/allowed-pe-files.txt
+++ b/mobile/apps/auth/windows/signing/allowed-pe-files.txt
@@ -3,7 +3,6 @@ auth.exe
connectivity_plus_plugin.dll
dartjni.dll
file_saver_plugin.dll
-flutter_local_authentication_plugin.dll
flutter_secure_storage_windows_plugin.dll
flutter_windows.dll
libsodium.dll
diff --git a/mobile/apps/locker/ios/Podfile.lock b/mobile/apps/locker/ios/Podfile.lock
index ca8da4816d..6c4b6563ba 100644
--- a/mobile/apps/locker/ios/Podfile.lock
+++ b/mobile/apps/locker/ios/Podfile.lock
@@ -47,8 +47,6 @@ PODS:
- Flutter (1.0.0)
- flutter_email_sender (0.0.1):
- Flutter
- - flutter_local_authentication (1.2.0):
- - Flutter
- flutter_native_splash (2.4.3):
- Flutter
- flutter_secure_storage (6.0.0):
@@ -100,7 +98,6 @@ DEPENDENCIES:
- file_saver (from `.symlinks/plugins/file_saver/ios`)
- Flutter (from `Flutter`)
- flutter_email_sender (from `.symlinks/plugins/flutter_email_sender/ios`)
- - flutter_local_authentication (from `.symlinks/plugins/flutter_local_authentication/ios`)
- flutter_native_splash (from `.symlinks/plugins/flutter_native_splash/ios`)
- flutter_secure_storage (from `.symlinks/plugins/flutter_secure_storage/ios`)
- fluttertoast (from `.symlinks/plugins/fluttertoast/ios`)
@@ -142,8 +139,6 @@ EXTERNAL SOURCES:
:path: Flutter
flutter_email_sender:
:path: ".symlinks/plugins/flutter_email_sender/ios"
- flutter_local_authentication:
- :path: ".symlinks/plugins/flutter_local_authentication/ios"
flutter_native_splash:
:path: ".symlinks/plugins/flutter_native_splash/ios"
flutter_secure_storage:
@@ -181,12 +176,11 @@ SPEC CHECKSUMS:
device_info_plus: 21fcca2080fbcd348be798aa36c3e5ed849eefbe
DKImagePickerController: 946cec48c7873164274ecc4624d19e3da4c1ef3c
DKPhotoGallery: b3834fecb755ee09a593d7c9e389d8b5d6deed60
- ente_rust: 9c976e3d083f0ce90f31693deb99629b28d8fe4c
+ ente_rust: d0197ebd5460e8f67576579452b073d698404abe
file_picker: a0560bc09d61de87f12d246fc47d2119e6ef37be
file_saver: 6cdbcddd690cb02b0c1a0c225b37cd805c2bf8b6
Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467
flutter_email_sender: aa1e9772696691d02cd91fea829856c11efb8e58
- flutter_local_authentication: 989278c681612f1ee0e36019e149137f114b9d7f
flutter_native_splash: c32d145d68aeda5502d5f543ee38c192065986cf
flutter_secure_storage: 2c2ff13db9e0a5647389bff88b0ecac56e3f3418
fluttertoast: 2c67e14dce98bbdb200df9e1acf610d7a6264ea1
diff --git a/mobile/apps/locker/linux/flutter/generated_plugin_registrant.cc b/mobile/apps/locker/linux/flutter/generated_plugin_registrant.cc
index fafe406725..711a150ddf 100644
--- a/mobile/apps/locker/linux/flutter/generated_plugin_registrant.cc
+++ b/mobile/apps/locker/linux/flutter/generated_plugin_registrant.cc
@@ -7,9 +7,9 @@
#include "generated_plugin_registrant.h"
#include <file_saver/file_saver_plugin.h>
-#include <flutter_local_authentication/flutter_local_authentication_plugin.h>
#include <flutter_secure_storage_linux/flutter_secure_storage_linux_plugin.h>
#include <gtk/gtk_plugin.h>
+#include <local_auth_linux/local_auth_linux_plugin.h>
#include <open_file_linux/open_file_linux_plugin.h>
#include <screen_retriever_linux/screen_retriever_linux_plugin.h>
#include <sentry_flutter/sentry_flutter_plugin.h>
@@ -22,15 +22,15 @@ void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) file_saver_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "FileSaverPlugin");
file_saver_plugin_register_with_registrar(file_saver_registrar);
- g_autoptr(FlPluginRegistrar) flutter_local_authentication_registrar =
- fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterLocalAuthenticationPlugin");
- flutter_local_authentication_plugin_register_with_registrar(flutter_local_authentication_registrar);
g_autoptr(FlPluginRegistrar) flutter_secure_storage_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterSecureStorageLinuxPlugin");
flutter_secure_storage_linux_plugin_register_with_registrar(flutter_secure_storage_linux_registrar);
g_autoptr(FlPluginRegistrar) gtk_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "GtkPlugin");
gtk_plugin_register_with_registrar(gtk_registrar);
+ g_autoptr(FlPluginRegistrar) local_auth_linux_registrar =
+ fl_plugin_registry_get_registrar_for_plugin(registry, "LocalAuthLinuxPlugin");
+ local_auth_linux_plugin_register_with_registrar(local_auth_linux_registrar);
g_autoptr(FlPluginRegistrar) open_file_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "OpenFileLinuxPlugin");
open_file_linux_plugin_register_with_registrar(open_file_linux_registrar);
diff --git a/mobile/apps/locker/linux/flutter/generated_plugins.cmake b/mobile/apps/locker/linux/flutter/generated_plugins.cmake
index 9c70bf7e7d..030f482592 100644
--- a/mobile/apps/locker/linux/flutter/generated_plugins.cmake
+++ b/mobile/apps/locker/linux/flutter/generated_plugins.cmake
@@ -4,9 +4,9 @@
list(APPEND FLUTTER_PLUGIN_LIST
file_saver
- flutter_local_authentication
flutter_secure_storage_linux
gtk
+ local_auth_linux
open_file_linux
screen_retriever_linux
sentry_flutter
diff --git a/mobile/apps/locker/macos/Flutter/GeneratedPluginRegistrant.swift b/mobile/apps/locker/macos/Flutter/GeneratedPluginRegistrant.swift
index cd629c0a3c..2897404432 100644
--- a/mobile/apps/locker/macos/Flutter/GeneratedPluginRegistrant.swift
+++ b/mobile/apps/locker/macos/Flutter/GeneratedPluginRegistrant.swift
@@ -9,7 +9,6 @@ import app_links
import device_info_plus
import file_picker
import file_saver
-import flutter_local_authentication
import flutter_secure_storage_macos
import local_auth_darwin
import open_file_mac
@@ -29,7 +28,6 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
FilePickerPlugin.register(with: registry.registrar(forPlugin: "FilePickerPlugin"))
FileSaverPlugin.register(with: registry.registrar(forPlugin: "FileSaverPlugin"))
- FlutterLocalAuthenticationPlugin.register(with: registry.registrar(forPlugin: "FlutterLocalAuthenticationPlugin"))
FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin"))
LocalAuthPlugin.register(with: registry.registrar(forPlugin: "LocalAuthPlugin"))
OpenFilePlugin.register(with: registry.registrar(forPlugin: "OpenFilePlugin"))
diff --git a/mobile/apps/locker/macos/Podfile.lock b/mobile/apps/locker/macos/Podfile.lock
index c8d61e5af3..046c1a736b 100644
--- a/mobile/apps/locker/macos/Podfile.lock
+++ b/mobile/apps/locker/macos/Podfile.lock
@@ -12,23 +12,16 @@ PODS:
- FlutterMacOS
- file_saver (0.0.1):
- FlutterMacOS
- - flutter_local_authentication (1.2.0):
- - FlutterMacOS
- flutter_secure_storage_macos (6.1.3):
- FlutterMacOS
- FlutterMacOS (1.0.0)
- local_auth_darwin (0.0.1):
- Flutter
- FlutterMacOS
- - objective_c (0.0.1):
- - FlutterMacOS
- open_file_mac (1.0.3):
- FlutterMacOS
- package_info_plus (0.0.1):
- FlutterMacOS
- - path_provider_foundation (0.0.1):
- - Flutter
- - FlutterMacOS
- screen_retriever_macos (0.0.1):
- FlutterMacOS
- Sentry/HybridSDK (8.46.0)
@@ -41,7 +34,7 @@ PODS:
- shared_preferences_foundation (0.0.1):
- Flutter
- FlutterMacOS
- - "sodium_libs (3.4.6+1)":
+ - "sodium_libs (3.4.6+4)":
- Flutter
- FlutterMacOS
- sqflite_darwin (0.0.4):
@@ -61,14 +54,11 @@ DEPENDENCIES:
- ente_rust (from `Flutter/ephemeral/.symlinks/plugins/ente_rust/macos`)
- file_picker (from `Flutter/ephemeral/.symlinks/plugins/file_picker/macos`)
- file_saver (from `Flutter/ephemeral/.symlinks/plugins/file_saver/macos`)
- - flutter_local_authentication (from `Flutter/ephemeral/.symlinks/plugins/flutter_local_authentication/macos`)
- flutter_secure_storage_macos (from `Flutter/ephemeral/.symlinks/plugins/flutter_secure_storage_macos/macos`)
- FlutterMacOS (from `Flutter/ephemeral`)
- local_auth_darwin (from `Flutter/ephemeral/.symlinks/plugins/local_auth_darwin/darwin`)
- - objective_c (from `Flutter/ephemeral/.symlinks/plugins/objective_c/macos`)
- open_file_mac (from `Flutter/ephemeral/.symlinks/plugins/open_file_mac/macos`)
- package_info_plus (from `Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos`)
- - path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`)
- screen_retriever_macos (from `Flutter/ephemeral/.symlinks/plugins/screen_retriever_macos/macos`)
- sentry_flutter (from `Flutter/ephemeral/.symlinks/plugins/sentry_flutter/macos`)
- share_plus (from `Flutter/ephemeral/.symlinks/plugins/share_plus/macos`)
@@ -96,22 +86,16 @@ EXTERNAL SOURCES:
:path: Flutter/ephemeral/.symlinks/plugins/file_picker/macos
file_saver:
:path: Flutter/ephemeral/.symlinks/plugins/file_saver/macos
- flutter_local_authentication:
- :path: Flutter/ephemeral/.symlinks/plugins/flutter_local_authentication/macos
flutter_secure_storage_macos:
:path: Flutter/ephemeral/.symlinks/plugins/flutter_secure_storage_macos/macos
FlutterMacOS:
:path: Flutter/ephemeral
local_auth_darwin:
:path: Flutter/ephemeral/.symlinks/plugins/local_auth_darwin/darwin
- objective_c:
- :path: Flutter/ephemeral/.symlinks/plugins/objective_c/macos
open_file_mac:
:path: Flutter/ephemeral/.symlinks/plugins/open_file_mac/macos
package_info_plus:
:path: Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos
- path_provider_foundation:
- :path: Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin
screen_retriever_macos:
:path: Flutter/ephemeral/.symlinks/plugins/screen_retriever_macos/macos
sentry_flutter:
@@ -135,26 +119,23 @@ SPEC CHECKSUMS:
app_links: 05a6ec2341985eb05e9f97dc63f5837c39895c3f
cupertino_http: 94ac07f5ff090b8effa6c5e2c47871d48ab7c86c
device_info_plus: 4fb280989f669696856f8b129e4a5e3cd6c48f76
- ente_rust: b02baa38e799c3bbcd2baf9a01d92f8dfb157758
+ ente_rust: c2cbe1847ce63acc8490ccfe97ebda021118adec
file_picker: 7584aae6fa07a041af2b36a2655122d42f578c1a
file_saver: e35bd97de451dde55ff8c38862ed7ad0f3418d0f
- flutter_local_authentication: 2f9a2682f498abcc12d7e9729b5007a947170fdc
flutter_secure_storage_macos: 7f45e30f838cf2659862a4e4e3ee1c347c2b3b54
- FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
- local_auth_darwin: d2e8c53ef0c4f43c646462e3415432c4dab3ae19
- objective_c: ec13431e45ba099cb734eb2829a5c1cd37986cba
+ FlutterMacOS: d0db08ddef1a9af05a5ec4b724367152bb0500b1
+ local_auth_darwin: c3ee6cce0a8d56be34c8ccb66ba31f7f180aaebb
open_file_mac: 76f06c8597551249bdb5e8fd8827a98eae0f4585
package_info_plus: f0052d280d17aa382b932f399edf32507174e870
- path_provider_foundation: 080d55be775b7414fd5a5ef3ac137b97b097e564
screen_retriever_macos: 452e51764a9e1cdb74b3c541238795849f21557f
Sentry: da60d980b197a46db0b35ea12cb8f39af48d8854
sentry_flutter: 27892878729f42701297c628eb90e7c6529f3684
share_plus: 510bf0af1a42cd602274b4629920c9649c52f4cc
- shared_preferences_foundation: 9e1978ff2562383bd5676f64ec4e9aa8fa06a6f7
- sodium_libs: ecc719aba13e1077057a4f550592d80bf68e9d69
+ shared_preferences_foundation: 7036424c3d8ec98dfe75ff1667cb0cd531ec82bb
+ sodium_libs: 650f802d77b08c737ca4fed4ed68e822fa560c5a
sqflite_darwin: 20b2a3a3b70e43edae938624ce550a3cbf66a3d0
tray_manager: a104b5c81b578d83f3c3d0f40a997c8b10810166
- url_launcher_macos: 0fba8ddabfc33ce0a9afe7c5fef5aab3d8d2d673
+ url_launcher_macos: f87a979182d112f911de6820aefddaf56ee9fbfd
window_manager: b729e31d38fb04905235df9ea896128991cad99e
PODFILE CHECKSUM: 9ebaf0ce3d369aaa26a9ea0e159195ed94724cf3
diff --git a/mobile/apps/locker/pubspec.lock b/mobile/apps/locker/pubspec.lock
index ae14f5468b..924d48f3fd 100644
--- a/mobile/apps/locker/pubspec.lock
+++ b/mobile/apps/locker/pubspec.lock
@@ -532,15 +532,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "4.0.0"
- flutter_local_authentication:
- dependency: "direct main"
- description:
- path: "."
- ref: "1ac346a04592a05fd75acccf2e01fa3c7e955d96"
- resolved-ref: "1ac346a04592a05fd75acccf2e01fa3c7e955d96"
- url: "https://github.com/eaceto/flutter_local_authentication"
- source: git
- version: "1.2.0"
flutter_localizations:
dependency: "direct main"
description: flutter
@@ -844,6 +835,13 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.3"
+ local_auth_linux:
+ dependency: transitive
+ description:
+ path: "../../packages/local_auth_linux"
+ relative: true
+ source: path
+ version: "0.1.0"
local_auth_platform_interface:
dependency: transitive
description:
diff --git a/mobile/apps/locker/pubspec.yaml b/mobile/apps/locker/pubspec.yaml
index d7a77e7fcf..7e41ca2caf 100644
--- a/mobile/apps/locker/pubspec.yaml
+++ b/mobile/apps/locker/pubspec.yaml
@@ -62,10 +62,6 @@ dependencies:
flutter:
sdk: flutter
flutter_displaymode: 0.6.0
- flutter_local_authentication:
- git:
- url: https://github.com/eaceto/flutter_local_authentication
- ref: 1ac346a04592a05fd75acccf2e01fa3c7e955d96
flutter_localizations:
sdk: flutter
flutter_svg: 2.2.3
diff --git a/mobile/apps/locker/windows/flutter/generated_plugin_registrant.cc b/mobile/apps/locker/windows/flutter/generated_plugin_registrant.cc
index d09d19889a..ce3538dc9e 100644
--- a/mobile/apps/locker/windows/flutter/generated_plugin_registrant.cc
+++ b/mobile/apps/locker/windows/flutter/generated_plugin_registrant.cc
@@ -8,7 +8,6 @@
#include <app_links/app_links_plugin_c_api.h>
#include <file_saver/file_saver_plugin.h>
-#include <flutter_local_authentication/flutter_local_authentication_plugin_c_api.h>
#include <flutter_secure_storage_windows/flutter_secure_storage_windows_plugin.h>
#include <local_auth_windows/local_auth_plugin.h>
#include <screen_retriever_windows/screen_retriever_windows_plugin_c_api.h>
@@ -24,8 +23,6 @@ void RegisterPlugins(flutter::PluginRegistry* registry) {
registry->GetRegistrarForPlugin("AppLinksPluginCApi"));
FileSaverPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FileSaverPlugin"));
- FlutterLocalAuthenticationPluginCApiRegisterWithRegistrar(
- registry->GetRegistrarForPlugin("FlutterLocalAuthenticationPluginCApi"));
FlutterSecureStorageWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FlutterSecureStorageWindowsPlugin"));
LocalAuthPluginRegisterWithRegistrar(
diff --git a/mobile/apps/locker/windows/flutter/generated_plugins.cmake b/mobile/apps/locker/windows/flutter/generated_plugins.cmake
index f5d98f9c29..77f2779d84 100644
--- a/mobile/apps/locker/windows/flutter/generated_plugins.cmake
+++ b/mobile/apps/locker/windows/flutter/generated_plugins.cmake
@@ -5,7 +5,6 @@
list(APPEND FLUTTER_PLUGIN_LIST
app_links
file_saver
- flutter_local_authentication
flutter_secure_storage_windows
local_auth_windows
screen_retriever_windows
diff --git a/mobile/packages/accounts/pubspec.lock b/mobile/packages/accounts/pubspec.lock
index 2ed5bd01c7..5369df55c0 100644
--- a/mobile/packages/accounts/pubspec.lock
+++ b/mobile/packages/accounts/pubspec.lock
@@ -347,15 +347,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "5.0.0"
- flutter_local_authentication:
- dependency: transitive
- description:
- path: "."
- ref: "1ac346a04592a05fd75acccf2e01fa3c7e955d96"
- resolved-ref: "1ac346a04592a05fd75acccf2e01fa3c7e955d96"
- url: "https://github.com/eaceto/flutter_local_authentication"
- source: git
- version: "1.2.0"
flutter_localizations:
dependency: transitive
description: flutter
@@ -603,6 +594,13 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.3"
+ local_auth_linux:
+ dependency: transitive
+ description:
+ path: "../local_auth_linux"
+ relative: true
+ source: path
+ version: "0.1.0"
local_auth_platform_interface:
dependency: transitive
description:
diff --git a/mobile/packages/legacy/pubspec.lock b/mobile/packages/legacy/pubspec.lock
index 62ca835ce1..1ddb8ef965 100644
--- a/mobile/packages/legacy/pubspec.lock
+++ b/mobile/packages/legacy/pubspec.lock
@@ -407,15 +407,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "5.0.0"
- flutter_local_authentication:
- dependency: transitive
- description:
- path: "."
- ref: "1ac346a04592a05fd75acccf2e01fa3c7e955d96"
- resolved-ref: "1ac346a04592a05fd75acccf2e01fa3c7e955d96"
- url: "https://github.com/eaceto/flutter_local_authentication"
- source: git
- version: "1.2.0"
flutter_localizations:
dependency: transitive
description: flutter
@@ -687,6 +678,13 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.3"
+ local_auth_linux:
+ dependency: transitive
+ description:
+ path: "../local_auth_linux"
+ relative: true
+ source: path
+ version: "0.1.0"
local_auth_platform_interface:
dependency: transitive
description:
diff --git a/mobile/packages/local_auth_linux/lib/local_auth_linux.dart b/mobile/packages/local_auth_linux/lib/local_auth_linux.dart
new file mode 100644
index 0000000000..2982c67050
--- /dev/null
+++ b/mobile/packages/local_auth_linux/lib/local_auth_linux.dart
@@ -0,0 +1,85 @@
+import 'package:flutter/foundation.dart';
+import 'package:flutter/services.dart';
+import 'package:local_auth_platform_interface/local_auth_platform_interface.dart';
+
+const MethodChannel _defaultChannel = MethodChannel('ente.io/local_auth_linux');
+
+class LocalAuthLinux extends LocalAuthPlatform {
+ LocalAuthLinux({@visibleForTesting MethodChannel? channel})
+ : _channel = channel ?? _defaultChannel;
+
+ final MethodChannel _channel;
+ bool _isAuthenticating = false;
+
+ static void registerWith() {
+ LocalAuthPlatform.instance = LocalAuthLinux();
+ }
+
+ @override
+ Future<bool> authenticate({
+ required String localizedReason,
+ required Iterable<AuthMessages> authMessages,
+ AuthenticationOptions options = const AuthenticationOptions(),
+ }) async {
+ assert(localizedReason.isNotEmpty);
+
+ if (options.biometricOnly) {
+ throw UnsupportedError(
+ "Linux PAM authentication doesn't support the biometricOnly parameter.",
+ );
+ }
+ if (_isAuthenticating) {
+ throw const LocalAuthException(
+ code: LocalAuthExceptionCode.authInProgress,
+ );
+ }
+
+ _isAuthenticating = true;
+ try {
+ return await _channel.invokeMethod<bool>(
+ 'authenticate',
+ <String, Object?>{'localizedReason': localizedReason},
+ ) ??
+ false;
+ } on PlatformException catch (e) {
+ throw _localAuthExceptionForPlatformException(e);
+ } finally {
+ _isAuthenticating = false;
+ }
+ }
+
+ @override
+ Future<bool> deviceSupportsBiometrics() async => false;
+
+ @override
+ Future<List<BiometricType>> getEnrolledBiometrics() async =>
+ <BiometricType>[];
+
+ @override
+ Future<bool> isDeviceSupported() async {
+ try {
+ return await _channel.invokeMethod<bool>('isDeviceSupported') ?? false;
+ } on PlatformException {
+ return false;
+ }
+ }
+
+ @override
+ Future<bool> stopAuthentication() async => false;
+}
+
+LocalAuthException _localAuthExceptionForPlatformException(
+ PlatformException error,
+) {
+ final code = switch (error.code) {
+ 'authentication_canceled' => LocalAuthExceptionCode.userCanceled,
+ 'ui_unavailable' => LocalAuthExceptionCode.uiUnavailable,
+ 'pam_unavailable' ||
+ 'unsupported_runtime' ||
+ 'account_unavailable' => LocalAuthExceptionCode.deviceError,
+ 'authentication_failed' => LocalAuthExceptionCode.unknownError,
+ 'pam_error' => LocalAuthExceptionCode.unknownError,
+ _ => LocalAuthExceptionCode.unknownError,
+ };
+ return LocalAuthException(code: code, description: error.message);
+}
diff --git a/mobile/packages/local_auth_linux/linux/CMakeLists.txt b/mobile/packages/local_auth_linux/linux/CMakeLists.txt
new file mode 100644
index 0000000000..88853aa01c
--- /dev/null
+++ b/mobile/packages/local_auth_linux/linux/CMakeLists.txt
@@ -0,0 +1,30 @@
+cmake_minimum_required(VERSION 3.10)
+set(PROJECT_NAME "local_auth_linux")
+project(${PROJECT_NAME} LANGUAGES CXX)
+
+set(PLUGIN_NAME "local_auth_linux_plugin")
+
+add_library(${PLUGIN_NAME} SHARED
+ "local_auth_linux_plugin.cc"
+)
+
+apply_standard_settings(${PLUGIN_NAME})
+set_target_properties(${PLUGIN_NAME} PROPERTIES
+ CXX_VISIBILITY_PRESET hidden)
+target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL)
+target_include_directories(${PLUGIN_NAME} INTERFACE
+ "${CMAKE_CURRENT_SOURCE_DIR}/include")
+
+find_library(PAM_LIBRARY pam)
+if(NOT PAM_LIBRARY)
+ message(FATAL_ERROR "libpam was not found. Install libpam0g-dev or the equivalent PAM development package.")
+endif()
+
+target_link_libraries(${PLUGIN_NAME} PRIVATE flutter)
+target_link_libraries(${PLUGIN_NAME} PRIVATE PkgConfig::GTK)
+target_link_libraries(${PLUGIN_NAME} PRIVATE ${PAM_LIBRARY})
+
+set(local_auth_linux_bundled_libraries
+ ""
+ PARENT_SCOPE
+)
diff --git a/mobile/packages/local_auth_linux/linux/include/local_auth_linux/local_auth_linux_plugin.h b/mobile/packages/local_auth_linux/linux/include/local_auth_linux/local_auth_linux_plugin.h
new file mode 100644
index 0000000000..0c868fcf12
--- /dev/null
+++ b/mobile/packages/local_auth_linux/linux/include/local_auth_linux/local_auth_linux_plugin.h
@@ -0,0 +1,26 @@
+#ifndef FLUTTER_PLUGIN_LOCAL_AUTH_LINUX_PLUGIN_H_
+#define FLUTTER_PLUGIN_LOCAL_AUTH_LINUX_PLUGIN_H_
+
+#include <flutter_linux/flutter_linux.h>
+
+G_BEGIN_DECLS
+
+#ifdef FLUTTER_PLUGIN_IMPL
+#define FLUTTER_PLUGIN_EXPORT __attribute__((visibility("default")))
+#else
+#define FLUTTER_PLUGIN_EXPORT
+#endif
+
+typedef struct _LocalAuthLinuxPlugin LocalAuthLinuxPlugin;
+typedef struct {
+ GObjectClass parent_class;
+} LocalAuthLinuxPluginClass;
+
+FLUTTER_PLUGIN_EXPORT GType local_auth_linux_plugin_get_type();
+
+FLUTTER_PLUGIN_EXPORT void local_auth_linux_plugin_register_with_registrar(
+ FlPluginRegistrar* registrar);
+
+G_END_DECLS
+
+#endif // FLUTTER_PLUGIN_LOCAL_AUTH_LINUX_PLUGIN_H_
diff --git a/mobile/packages/local_auth_linux/linux/local_auth_linux_plugin.cc b/mobile/packages/local_auth_linux/linux/local_auth_linux_plugin.cc
new file mode 100644
index 0000000000..f45acb40b9
--- /dev/null
+++ b/mobile/packages/local_auth_linux/linux/local_auth_linux_plugin.cc
@@ -0,0 +1,356 @@
+#include "include/local_auth_linux/local_auth_linux_plugin.h"
+
+#include <flutter_linux/flutter_linux.h>
+#include <gtk/gtk.h>
+#include <pwd.h>
+#include <security/pam_appl.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <cstdlib>
+#include <cstring>
+
+#define LOCAL_AUTH_LINUX_PLUGIN(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), local_auth_linux_plugin_get_type(), \
+ LocalAuthLinuxPlugin))
+
+static constexpr const char* kChannelName = "ente.io/local_auth_linux";
+static constexpr const char* kDefaultPamService = "login";
+static constexpr const char* kPamServiceEnv = "ENTE_LOCAL_AUTH_PAM_SERVICE";
+
+struct _LocalAuthLinuxPlugin {
+ GObject parent_instance;
+};
+
+G_DEFINE_TYPE(LocalAuthLinuxPlugin, local_auth_linux_plugin,
+ g_object_get_type())
+
+struct _LocalAuthLinuxPluginClass {
+ GObjectClass parent_class;
+};
+
+struct PamConversationData {
+ const gchar* title;
+ const gchar* reason;
+ const gchar* cancel_button;
+ gboolean cancelled;
+};
+
+static const gchar* string_or_default(const gchar* value,
+ const gchar* fallback) {
+ return value != nullptr && value[0] != '\0' ? value : fallback;
+}
+
+static const char* pam_service_name() {
+ const char* service_name = std::getenv(kPamServiceEnv);
+ return service_name != nullptr && service_name[0] != '\0' ? service_name
+ : kDefaultPamService;
+}
+
+static const char* current_user_name() {
+ passwd* user = getpwuid(getuid());
+ return user != nullptr ? user->pw_name : nullptr;
+}
+
+static FlMethodResponse* error_response(const gchar* code,
+ const gchar* message) {
+ return FL_METHOD_RESPONSE(
+ fl_method_error_response_new(code, message, nullptr));
+}
+
+static const gchar* value_lookup_string(FlValue* map, const gchar* key) {
+ if (map == nullptr || fl_value_get_type(map) != FL_VALUE_TYPE_MAP) {
+ return nullptr;
+ }
+ g_autoptr(FlValue) lookup_key = fl_value_new_string(key);
+ FlValue* value = fl_value_lookup(map, lookup_key);
+ if (value == nullptr || fl_value_get_type(value) != FL_VALUE_TYPE_STRING) {
+ return nullptr;
+ }
+ return fl_value_get_string(value);
+}
+
+static gchar* show_prompt_dialog(PamConversationData* data,
+ const char* message,
+ gboolean secret) {
+ GtkWidget* dialog = gtk_dialog_new_with_buttons(
+ string_or_default(data->title, "Authentication required"), nullptr,
+ GTK_DIALOG_MODAL, string_or_default(data->cancel_button, "Cancel"),
+ GTK_RESPONSE_CANCEL, "OK", GTK_RESPONSE_OK, nullptr);
+
+ gtk_window_set_keep_above(GTK_WINDOW(dialog), TRUE);
+ gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);
+
+ GtkWidget* content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
+ gtk_container_set_border_width(GTK_CONTAINER(content_area), 16);
+
+ const gchar* reason = string_or_default(data->reason, "");
+ if (reason[0] != '\0') {
+ GtkWidget* reason_label = gtk_label_new(reason);
+ gtk_label_set_line_wrap(GTK_LABEL(reason_label), TRUE);
+ gtk_label_set_xalign(GTK_LABEL(reason_label), 0.0);
+ gtk_box_pack_start(GTK_BOX(content_area), reason_label, FALSE, FALSE, 8);
+ }
+
+ GtkWidget* message_label =
+ gtk_label_new(string_or_default(message, "Password"));
+ gtk_label_set_line_wrap(GTK_LABEL(message_label), TRUE);
+ gtk_label_set_xalign(GTK_LABEL(message_label), 0.0);
+ gtk_box_pack_start(GTK_BOX(content_area), message_label, FALSE, FALSE, 8);
+
+ GtkWidget* entry = gtk_entry_new();
+ gtk_entry_set_visibility(GTK_ENTRY(entry), !secret);
+ gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE);
+ gtk_box_pack_start(GTK_BOX(content_area), entry, FALSE, FALSE, 0);
+
+ gtk_widget_show_all(dialog);
+ gint response = gtk_dialog_run(GTK_DIALOG(dialog));
+ gchar* result = nullptr;
+ if (response == GTK_RESPONSE_OK) {
+ result = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry)));
+ } else {
+ data->cancelled = TRUE;
+ }
+
+ gtk_widget_destroy(dialog);
+ while (gtk_events_pending()) {
+ gtk_main_iteration();
+ }
+ return result;
+}
+
+static void show_message_dialog(PamConversationData* data,
+ const char* message,
+ GtkMessageType type) {
+ GtkWidget* dialog = gtk_message_dialog_new(
+ nullptr, GTK_DIALOG_MODAL, type, GTK_BUTTONS_OK, "%s",
+ string_or_default(message, ""));
+ gtk_window_set_title(GTK_WINDOW(dialog),
+ string_or_default(data->title, "Authentication"));
+ gtk_window_set_keep_above(GTK_WINDOW(dialog), TRUE);
+ gtk_dialog_run(GTK_DIALOG(dialog));
+ gtk_widget_destroy(dialog);
+ while (gtk_events_pending()) {
+ gtk_main_iteration();
+ }
+}
+
+static void free_pam_responses(pam_response* responses, int count) {
+ if (responses == nullptr) {
+ return;
+ }
+ for (int i = 0; i < count; i++) {
+ std::free(responses[i].resp);
+ }
+ std::free(responses);
+}
+
+static int pam_conversation(int num_msg,
+ const struct pam_message** msg,
+ struct pam_response** resp,
+ void* appdata_ptr) {
+ if (num_msg <= 0 || msg == nullptr || resp == nullptr ||
+ appdata_ptr == nullptr) {
+ return PAM_CONV_ERR;
+ }
+
+ PamConversationData* data =
+ static_cast<PamConversationData*>(appdata_ptr);
+ pam_response* responses =
+ static_cast<pam_response*>(std::calloc(num_msg, sizeof(pam_response)));
+ if (responses == nullptr) {
+ return PAM_BUF_ERR;
+ }
+
+ for (int i = 0; i < num_msg; i++) {
+ const char* message = msg[i]->msg != nullptr ? msg[i]->msg : "";
+ switch (msg[i]->msg_style) {
+ case PAM_PROMPT_ECHO_ON:
+ case PAM_PROMPT_ECHO_OFF: {
+ g_autofree gchar* answer =
+ show_prompt_dialog(data, message,
+ msg[i]->msg_style == PAM_PROMPT_ECHO_OFF);
+ if (data->cancelled || answer == nullptr) {
+ free_pam_responses(responses, i);
+ return PAM_CONV_ERR;
+ }
+ responses[i].resp = strdup(answer);
+ if (responses[i].resp == nullptr) {
+ free_pam_responses(responses, i);
+ return PAM_BUF_ERR;
+ }
+ break;
+ }
+ case PAM_TEXT_INFO:
+ show_message_dialog(data, message, GTK_MESSAGE_INFO);
+ break;
+ case PAM_ERROR_MSG:
+ show_message_dialog(data, message, GTK_MESSAGE_ERROR);
+ break;
+ default:
+ free_pam_responses(responses, i);
+ return PAM_CONV_ERR;
+ }
+ }
+
+ *resp = responses;
+ return PAM_SUCCESS;
+}
+
+static gboolean can_authenticate_with_pam() {
+ const char* user_name = current_user_name();
+ if (user_name == nullptr) {
+ return FALSE;
+ }
+
+ pam_handle_t* pam_handle = nullptr;
+ pam_conv conversation = {nullptr, nullptr};
+ int status =
+ pam_start(pam_service_name(), user_name, &conversation, &pam_handle);
+ if (pam_handle != nullptr) {
+ pam_end(pam_handle, status);
+ }
+ return status == PAM_SUCCESS;
+}
+
+static gboolean authenticate_with_pam(const gchar* reason,
+ gchar** error_code,
+ gchar** error_message,
+ gboolean* authentication_failed) {
+ if (gdk_display_get_default() == nullptr) {
+ *error_code = g_strdup("ui_unavailable");
+ *error_message = g_strdup("No GTK display is available.");
+ return FALSE;
+ }
+
+ const char* user_name = current_user_name();
+ if (user_name == nullptr) {
+ *error_code = g_strdup("unsupported_runtime");
+ *error_message = g_strdup("Unable to determine the current user.");
+ return FALSE;
+ }
+
+ PamConversationData conversation_data = {
+ "Authentication required",
+ string_or_default(reason, "Authenticate with your system password."),
+ "Cancel", FALSE};
+ pam_conv conversation = {pam_conversation, &conversation_data};
+ pam_handle_t* pam_handle = nullptr;
+
+ int status =
+ pam_start(pam_service_name(), user_name, &conversation, &pam_handle);
+ if (status != PAM_SUCCESS) {
+ *error_code = g_strdup("pam_unavailable");
+ *error_message = g_strdup(pam_strerror(pam_handle, status));
+ if (pam_handle != nullptr) {
+ pam_end(pam_handle, status);
+ }
+ return FALSE;
+ }
+
+ status = pam_authenticate(pam_handle, 0);
+ if (status == PAM_SUCCESS) {
+ status = pam_acct_mgmt(pam_handle, 0);
+ }
+
+ g_autofree gchar* pam_message = g_strdup(pam_strerror(pam_handle, status));
+ pam_end(pam_handle, status);
+
+ if (status == PAM_SUCCESS) {
+ return TRUE;
+ }
+
+ if (conversation_data.cancelled) {
+ *error_code = g_strdup("authentication_canceled");
+ *error_message = g_strdup("Authentication was canceled.");
+ } else if (status == PAM_AUTH_ERR || status == PAM_USER_UNKNOWN ||
+ status == PAM_MAXTRIES) {
+ *authentication_failed = TRUE;
+ *error_message =
+ g_strdup(string_or_default(pam_message, "Authentication failed."));
+ } else if (status == PAM_ACCT_EXPIRED || status == PAM_PERM_DENIED ||
+ status == PAM_NEW_AUTHTOK_REQD) {
+ *error_code = g_strdup("account_unavailable");
+ *error_message =
+ g_strdup(string_or_default(pam_message, "Account is unavailable."));
+ } else {
+ *error_code = g_strdup("pam_error");
+ *error_message =
+ g_strdup(string_or_default(pam_message, "PAM authentication failed."));
+ }
+ return FALSE;
+}
+
+static void local_auth_linux_plugin_handle_method_call(
+ LocalAuthLinuxPlugin* self,
+ FlMethodCall* method_call) {
+ (void)self;
+ g_autoptr(FlMethodResponse) response = nullptr;
+ const gchar* method = fl_method_call_get_name(method_call);
+
+ if (strcmp(method, "isDeviceSupported") == 0) {
+ g_autoptr(FlValue) result =
+ fl_value_new_bool(can_authenticate_with_pam());
+ response = FL_METHOD_RESPONSE(fl_method_success_response_new(result));
+ } else if (strcmp(method, "authenticate") == 0) {
+ FlValue* arguments = fl_method_call_get_args(method_call);
+ const gchar* reason = value_lookup_string(arguments, "localizedReason");
+ g_autofree gchar* error_code = nullptr;
+ g_autofree gchar* error_message = nullptr;
+ gboolean authentication_failed = FALSE;
+
+ if (authenticate_with_pam(reason, &error_code, &error_message,
+ &authentication_failed)) {
+ g_autoptr(FlValue) result = fl_value_new_bool(TRUE);
+ response = FL_METHOD_RESPONSE(fl_method_success_response_new(result));
+ } else if (authentication_failed) {
+ g_autoptr(FlValue) result = fl_value_new_bool(FALSE);
+ response = FL_METHOD_RESPONSE(fl_method_success_response_new(result));
+ } else {
+ response = error_response(
+ string_or_default(error_code, "pam_error"),
+ string_or_default(error_message, "Authentication failed."));
+ }
+ } else {
+ response = FL_METHOD_RESPONSE(fl_method_not_implemented_response_new());
+ }
+
+ fl_method_call_respond(method_call, response, nullptr);
+}
+
+static void local_auth_linux_plugin_dispose(GObject* object) {
+ G_OBJECT_CLASS(local_auth_linux_plugin_parent_class)->dispose(object);
+}
+
+static void local_auth_linux_plugin_class_init(
+ LocalAuthLinuxPluginClass* klass) {
+ G_OBJECT_CLASS(klass)->dispose = local_auth_linux_plugin_dispose;
+}
+
+static void local_auth_linux_plugin_init(LocalAuthLinuxPlugin* self) {
+ (void)self;
+}
+
+static void method_call_cb(FlMethodChannel* channel,
+ FlMethodCall* method_call,
+ gpointer user_data) {
+ (void)channel;
+ LocalAuthLinuxPlugin* plugin = LOCAL_AUTH_LINUX_PLUGIN(user_data);
+ local_auth_linux_plugin_handle_method_call(plugin, method_call);
+}
+
+void local_auth_linux_plugin_register_with_registrar(
+ FlPluginRegistrar* registrar) {
+ LocalAuthLinuxPlugin* plugin = LOCAL_AUTH_LINUX_PLUGIN(
+ g_object_new(local_auth_linux_plugin_get_type(), nullptr));
+
+ g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new();
+ g_autoptr(FlMethodChannel) channel = fl_method_channel_new(
+ fl_plugin_registrar_get_messenger(registrar), kChannelName,
+ FL_METHOD_CODEC(codec));
+ fl_method_channel_set_method_call_handler(channel, method_call_cb,
+ g_object_ref(plugin),
+ g_object_unref);
+
+ g_object_unref(plugin);
+}
diff --git a/mobile/packages/local_auth_linux/pubspec.lock b/mobile/packages/local_auth_linux/pubspec.lock
new file mode 100644
index 0000000000..7f5249a4a5
--- /dev/null
+++ b/mobile/packages/local_auth_linux/pubspec.lock
@@ -0,0 +1,221 @@
+# Generated by pub
+# See https://dart.dev/tools/pub/glossary#lockfile
+packages:
+ async:
+ dependency: transitive
+ description:
+ name: async
+ sha256: e2eb0491ba5ddb6177742d2da23904574082139b07c1e33b8503b9f46f3e1a37
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.13.1"
+ boolean_selector:
+ dependency: transitive
+ description:
+ name: boolean_selector
+ sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea"
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.1.2"
+ characters:
+ dependency: transitive
+ description:
+ name: characters
+ sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.4.0"
+ clock:
+ dependency: transitive
+ description:
+ name: clock
+ sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.1.2"
+ collection:
+ dependency: transitive
+ description:
+ name: collection
+ sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.19.1"
+ fake_async:
+ dependency: transitive
+ description:
+ name: fake_async
+ sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.3.3"
+ flutter:
+ dependency: "direct main"
+ description: flutter
+ source: sdk
+ version: "0.0.0"
+ flutter_lints:
+ dependency: "direct dev"
+ description:
+ name: flutter_lints
+ sha256: "5398f14efa795ffb7a33e9b6a08798b26a180edac4ad7db3f231e40f82ce11e1"
+ url: "https://pub.dev"
+ source: hosted
+ version: "5.0.0"
+ flutter_test:
+ dependency: "direct dev"
+ description: flutter
+ source: sdk
+ version: "0.0.0"
+ leak_tracker:
+ dependency: transitive
+ description:
+ name: leak_tracker
+ sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de"
+ url: "https://pub.dev"
+ source: hosted
+ version: "11.0.2"
+ leak_tracker_flutter_testing:
+ dependency: transitive
+ description:
+ name: leak_tracker_flutter_testing
+ sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1"
+ url: "https://pub.dev"
+ source: hosted
+ version: "3.0.10"
+ leak_tracker_testing:
+ dependency: transitive
+ description:
+ name: leak_tracker_testing
+ sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1"
+ url: "https://pub.dev"
+ source: hosted
+ version: "3.0.2"
+ lints:
+ dependency: transitive
+ description:
+ name: lints
+ sha256: c35bb79562d980e9a453fc715854e1ed39e24e7d0297a880ef54e17f9874a9d7
+ url: "https://pub.dev"
+ source: hosted
+ version: "5.1.1"
+ local_auth_platform_interface:
+ dependency: "direct main"
+ description:
+ name: local_auth_platform_interface
+ sha256: f98b8e388588583d3f781f6806e4f4c9f9e189d898d27f0c249b93a1973dd122
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.1.0"
+ matcher:
+ dependency: transitive
+ description:
+ name: matcher
+ sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.12.17"
+ material_color_utilities:
+ dependency: transitive
+ description:
+ name: material_color_utilities
+ sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.11.1"
+ meta:
+ dependency: transitive
+ description:
+ name: meta
+ sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.17.0"
+ path:
+ dependency: transitive
+ description:
+ name: path
+ sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.9.1"
+ plugin_platform_interface:
+ dependency: transitive
+ description:
+ name: plugin_platform_interface
+ sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02"
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.1.8"
+ sky_engine:
+ dependency: transitive
+ description: flutter
+ source: sdk
+ version: "0.0.0"
+ source_span:
+ dependency: transitive
+ description:
+ name: source_span
+ sha256: "56a02f1f4cd1a2d96303c0144c93bd6d909eea6bee6bf5a0e0b685edbd4c47ab"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.10.2"
+ stack_trace:
+ dependency: transitive
+ description:
+ name: stack_trace
+ sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.12.1"
+ stream_channel:
+ dependency: transitive
+ description:
+ name: stream_channel
+ sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d"
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.1.4"
+ string_scanner:
+ dependency: transitive
+ description:
+ name: string_scanner
+ sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.4.1"
+ term_glyph:
+ dependency: transitive
+ description:
+ name: term_glyph
+ sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.2.2"
+ test_api:
+ dependency: transitive
+ description:
+ name: test_api
+ sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.7.7"
+ vector_math:
+ dependency: transitive
+ description:
+ name: vector_math
+ sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.2.0"
+ vm_service:
+ dependency: transitive
+ description:
+ name: vm_service
+ sha256: "0016aef94fc66495ac78af5859181e3f3bf2026bd8eecc72b9565601e19ab360"
+ url: "https://pub.dev"
+ source: hosted
+ version: "15.2.0"
+sdks:
+ dart: ">=3.10.0 <4.0.0"
+ flutter: ">=3.32.0"
diff --git a/mobile/packages/local_auth_linux/pubspec.yaml b/mobile/packages/local_auth_linux/pubspec.yaml
new file mode 100644
index 0000000000..6a07c51060
--- /dev/null
+++ b/mobile/packages/local_auth_linux/pubspec.yaml
@@ -0,0 +1,26 @@
+name: local_auth_linux
+description: Linux implementation of the local_auth plugin for Ente.
+version: 0.1.0
+publish_to: none
+
+environment:
+ sdk: ">=3.10.0 <4.0.0"
+ flutter: ">=3.32.0"
+
+flutter:
+ plugin:
+ implements: local_auth
+ platforms:
+ linux:
+ pluginClass: LocalAuthLinuxPlugin
+ dartPluginClass: LocalAuthLinux
+
+dependencies:
+ flutter:
+ sdk: flutter
+ local_auth_platform_interface: 1.1.0
+
+dev_dependencies:
+ flutter_lints: 5.0.0
+ flutter_test:
+ sdk: flutter
diff --git a/mobile/packages/local_auth_linux/test/local_auth_linux_test.dart b/mobile/packages/local_auth_linux/test/local_auth_linux_test.dart
new file mode 100644
index 0000000000..8f19e36a10
--- /dev/null
+++ b/mobile/packages/local_auth_linux/test/local_auth_linux_test.dart
@@ -0,0 +1,140 @@
+import 'dart:async';
+
+import 'package:flutter/services.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:local_auth_linux/local_auth_linux.dart';
+import 'package:local_auth_platform_interface/local_auth_platform_interface.dart';
+
+void main() {
+ TestWidgetsFlutterBinding.ensureInitialized();
+
+ const channel = MethodChannel('test.local_auth_linux');
+ late LocalAuthLinux localAuth;
+ late List<MethodCall> calls;
+
+ setUp(() {
+ localAuth = LocalAuthLinux(channel: channel);
+ calls = <MethodCall>[];
+ TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
+ .setMockMethodCallHandler(channel, (MethodCall methodCall) async {
+ calls.add(methodCall);
+ return switch (methodCall.method) {
+ 'authenticate' => true,
+ 'isDeviceSupported' => true,
+ _ => null,
+ };
+ });
+ });
+
+ tearDown(() {
+ TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
+ .setMockMethodCallHandler(channel, null);
+ });
+
+ test('registers as the local_auth platform implementation', () {
+ final previous = LocalAuthPlatform.instance;
+
+ LocalAuthLinux.registerWith();
+
+ expect(LocalAuthPlatform.instance, isA<LocalAuthLinux>());
+ LocalAuthPlatform.instance = previous;
+ });
+
+ test('authenticate sends the localized reason to native code', () async {
+ final result = await localAuth.authenticate(
+ localizedReason: 'Unlock Ente Auth',
+ authMessages: const <AuthMessages>[],
+ );
+
+ expect(result, isTrue);
+ expect(calls.single.method, 'authenticate');
+ expect(calls.single.arguments, <String, Object?>{
+ 'localizedReason': 'Unlock Ente Auth',
+ });
+ });
+
+ test(
+ 'authenticate returns false when native auth rejects credentials',
+ () async {
+ TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
+ .setMockMethodCallHandler(channel, (_) async => false);
+
+ final result = await localAuth.authenticate(
+ localizedReason: 'Unlock Ente Auth',
+ authMessages: const <AuthMessages>[],
+ );
+
+ expect(result, isFalse);
+ },
+ );
+
+ test('authenticate maps cancellation to LocalAuthException', () async {
+ TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
+ .setMockMethodCallHandler(channel, (_) async {
+ throw PlatformException(
+ code: 'authentication_canceled',
+ message: 'Authentication was canceled.',
+ );
+ });
+
+ await expectLater(
+ localAuth.authenticate(
+ localizedReason: 'Unlock Ente Auth',
+ authMessages: const <AuthMessages>[],
+ ),
+ throwsA(
+ isA<LocalAuthException>().having(
+ (e) => e.code,
+ 'code',
+ LocalAuthExceptionCode.userCanceled,
+ ),
+ ),
+ );
+ });
+
+ test('authenticate rejects biometricOnly', () async {
+ await expectLater(
+ localAuth.authenticate(
+ localizedReason: 'Unlock Ente Auth',
+ authMessages: const <AuthMessages>[],
+ options: const AuthenticationOptions(biometricOnly: true),
+ ),
+ throwsUnsupportedError,
+ );
+ });
+
+ test('authenticate guards concurrent calls', () async {
+ final completer = Completer<bool>();
+ TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
+ .setMockMethodCallHandler(channel, (_) => completer.future);
+
+ final first = localAuth.authenticate(
+ localizedReason: 'Unlock Ente Auth',
+ authMessages: const <AuthMessages>[],
+ );
+
+ await expectLater(
+ localAuth.authenticate(
+ localizedReason: 'Unlock Ente Auth',
+ authMessages: const <AuthMessages>[],
+ ),
+ throwsA(
+ isA<LocalAuthException>().having(
+ (e) => e.code,
+ 'code',
+ LocalAuthExceptionCode.authInProgress,
+ ),
+ ),
+ );
+
+ completer.complete(true);
+ await expectLater(first, completion(isTrue));
+ });
+
+ test('reports PAM device support but no direct biometric support', () async {
+ expect(await localAuth.isDeviceSupported(), isTrue);
+ expect(await localAuth.deviceSupportsBiometrics(), isFalse);
+ expect(await localAuth.getEnrolledBiometrics(), isEmpty);
+ expect(await localAuth.stopAuthentication(), isFalse);
+ });
+}
diff --git a/mobile/packages/lock_screen/lib/auth_util.dart b/mobile/packages/lock_screen/lib/auth_util.dart
index f60c966e55..b581499fe3 100644
--- a/mobile/packages/lock_screen/lib/auth_util.dart
+++ b/mobile/packages/lock_screen/lib/auth_util.dart
@@ -5,7 +5,6 @@ import 'package:ente_lock_screen/lock_screen_settings.dart';
import 'package:ente_strings/ente_strings.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/services.dart';
-import 'package:flutter_local_authentication/flutter_local_authentication.dart';
import 'package:local_auth/local_auth.dart';
import 'package:local_auth_android/local_auth_android.dart';
import 'package:local_auth_darwin/types/auth_messages_ios.dart';
@@ -270,84 +269,76 @@ Future<bool> requestAuthentication(
isAuthenticatingForInAppChange: isAuthenticatingForInAppChange,
);
}
- if (Platform.isLinux) {
- // Linux uses flutter_local_authentication
- _logger.info("Starting Linux local authentication");
- final result = await FlutterLocalAuthentication().authenticate();
- _logger.info("Linux local authentication result: $result");
+ final localAuth = LocalAuthentication();
+ try {
+ await localAuth.stopAuthentication();
+ await _logLocalAuthState(localAuth);
+ final l10n = context.strings;
+ final result = await localAuth.authenticate(
+ localizedReason: Platform.isMacOS ? macOSReason : defaultReason,
+ authMessages: [
+ AndroidAuthMessages(
+ cancelButton: l10n.androidCancelButton,
+ signInHint: l10n.androidBiometricHint,
+ signInTitle: l10n.androidSignInTitle,
+ ),
+ IOSAuthMessages(
+ cancelButton: l10n.iOSOkButton,
+ localizedFallbackTitle: l10n.enterPassword,
+ ),
+ MacOSAuthMessages(
+ cancelButton: l10n.iOSOkButton,
+ localizedFallbackTitle: l10n.enterPassword,
+ ),
+ ],
+ );
+ if (Platform.isWindows || Platform.isLinux) {
+ _logger.info("System local authentication result: $result");
+ }
return result;
- } else {
- final localAuth = LocalAuthentication();
- try {
- await localAuth.stopAuthentication();
- await _logLocalAuthState(localAuth);
- final l10n = context.strings;
- final result = await localAuth.authenticate(
- localizedReason: Platform.isMacOS ? macOSReason : defaultReason,
- authMessages: [
- AndroidAuthMessages(
- cancelButton: l10n.androidCancelButton,
- signInHint: l10n.androidBiometricHint,
- signInTitle: l10n.androidSignInTitle,
- ),
- IOSAuthMessages(
- cancelButton: l10n.iOSOkButton,
- localizedFallbackTitle: l10n.enterPassword,
- ),
- MacOSAuthMessages(
- cancelButton: l10n.iOSOkButton,
- localizedFallbackTitle: l10n.enterPassword,
- ),
- ],
- );
- if (Platform.isWindows) {
- _logger.info("Windows local authentication result: $result");
- }
- return result;
- } on LocalAuthException catch (e, s) {
- final windowsException = Platform.isWindows
- ? windowsLocalAuthenticationExceptionForError(e)
- : null;
- if (windowsException != null) {
- _logger.warning("Windows local authentication failed", e, s);
- throw windowsException;
- }
- final unavailableException =
- localAuthenticationUnavailableExceptionForError(e);
- if (unavailableException != null) {
- _logger.warning("System local authentication unavailable", e, s);
- throw unavailableException;
- }
- if (isExpectedLocalAuthFailure(e)) {
- _logger.fine(
- "Local authentication did not complete: "
- "${e.code.name}, ${e.description}",
- );
- return false;
- }
- _logger.warning("System local authentication failed", e, s);
- rethrow;
- } on PlatformException catch (e, s) {
- final windowsException = Platform.isWindows
- ? windowsLocalAuthenticationExceptionForError(e)
- : null;
- if (windowsException == null) {
- _logger.warning("System local authentication platform error", e, s);
- rethrow;
- }
- _logger.warning("Windows local authentication failed", e, s);
- throw windowsException;
- } catch (e, s) {
- final windowsException = Platform.isWindows
- ? windowsLocalAuthenticationExceptionForError(e)
- : null;
- if (windowsException == null) {
- _logger.warning("Unexpected system local authentication error", e, s);
- rethrow;
- }
+ } on LocalAuthException catch (e, s) {
+ final windowsException = Platform.isWindows
+ ? windowsLocalAuthenticationExceptionForError(e)
+ : null;
+ if (windowsException != null) {
_logger.warning("Windows local authentication failed", e, s);
throw windowsException;
}
+ final unavailableException =
+ localAuthenticationUnavailableExceptionForError(e);
+ if (unavailableException != null) {
+ _logger.warning("System local authentication unavailable", e, s);
+ throw unavailableException;
+ }
+ if (isExpectedLocalAuthFailure(e)) {
+ _logger.fine(
+ "Local authentication did not complete: "
+ "${e.code.name}, ${e.description}",
+ );
+ return false;
+ }
+ _logger.warning("System local authentication failed", e, s);
+ rethrow;
+ } on PlatformException catch (e, s) {
+ final windowsException = Platform.isWindows
+ ? windowsLocalAuthenticationExceptionForError(e)
+ : null;
+ if (windowsException == null) {
+ _logger.warning("System local authentication platform error", e, s);
+ rethrow;
+ }
+ _logger.warning("Windows local authentication failed", e, s);
+ throw windowsException;
+ } catch (e, s) {
+ final windowsException = Platform.isWindows
+ ? windowsLocalAuthenticationExceptionForError(e)
+ : null;
+ if (windowsException == null) {
+ _logger.warning("Unexpected system local authentication error", e, s);
+ rethrow;
+ }
+ _logger.warning("Windows local authentication failed", e, s);
+ throw windowsException;
}
}
diff --git a/mobile/packages/lock_screen/lib/local_authentication_service.dart b/mobile/packages/lock_screen/lib/local_authentication_service.dart
index 13bee824cc..7a66b24de7 100644
--- a/mobile/packages/lock_screen/lib/local_authentication_service.dart
+++ b/mobile/packages/lock_screen/lib/local_authentication_service.dart
@@ -12,7 +12,6 @@ import 'package:ente_utils/platform_util.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
-import 'package:flutter_local_authentication/flutter_local_authentication.dart';
import 'package:local_auth/local_auth.dart';
import 'package:logging/logging.dart';
@@ -191,16 +190,6 @@ class LocalAuthenticationService {
);
return isSupported;
}
- if (Platform.isLinux) {
- logger.fine("Checking Linux local authentication support");
- final canAuthenticate = await FlutterLocalAuthentication()
- .canAuthenticate();
- logger.fine(
- "Linux local authentication support: "
- "canAuthenticate=$canAuthenticate",
- );
- return canAuthenticate;
- }
return await LocalAuthentication().isDeviceSupported();
} on MissingPluginException {
logger.warning("Local authentication plugin is not available");
diff --git a/mobile/packages/lock_screen/pubspec.lock b/mobile/packages/lock_screen/pubspec.lock
index 739a948e18..07c3802aeb 100644
--- a/mobile/packages/lock_screen/pubspec.lock
+++ b/mobile/packages/lock_screen/pubspec.lock
@@ -347,15 +347,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "5.0.0"
- flutter_local_authentication:
- dependency: "direct main"
- description:
- path: "."
- ref: "1ac346a04592a05fd75acccf2e01fa3c7e955d96"
- resolved-ref: "1ac346a04592a05fd75acccf2e01fa3c7e955d96"
- url: "https://github.com/eaceto/flutter_local_authentication"
- source: git
- version: "1.2.0"
flutter_localizations:
dependency: transitive
description: flutter
@@ -603,6 +594,13 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.3"
+ local_auth_linux:
+ dependency: "direct main"
+ description:
+ path: "../local_auth_linux"
+ relative: true
+ source: path
+ version: "0.1.0"
local_auth_platform_interface:
dependency: transitive
description:
diff --git a/mobile/packages/lock_screen/pubspec.yaml b/mobile/packages/lock_screen/pubspec.yaml
index 55c18a2310..41eb72cfd2 100644
--- a/mobile/packages/lock_screen/pubspec.yaml
+++ b/mobile/packages/lock_screen/pubspec.yaml
@@ -27,10 +27,6 @@ dependencies:
flutter:
sdk: flutter
flutter_animate: 4.5.2
- flutter_local_authentication:
- git:
- url: https://github.com/eaceto/flutter_local_authentication
- ref: 1ac346a04592a05fd75acccf2e01fa3c7e955d96
# Do not upgrade this package unless this issue is resolved:
# https://github.com/juliansteenbakker/flutter_secure_storage/issues/870
# On v9.2.4, keys related to lockscreen persist even after reintsall. For context see:
@@ -42,6 +38,8 @@ dependencies:
local_auth: 3.0.1
local_auth_android: 2.0.8
local_auth_darwin: 2.0.3
+ local_auth_linux:
+ path: ../local_auth_linux
logging: 1.3.0
pinput: 5.0.2
privacy_screen: 0.0.8
diff --git a/mobile/packages/sharing/pubspec.lock b/mobile/packages/sharing/pubspec.lock
index 3d21771e9b..98a5c3e779 100644
--- a/mobile/packages/sharing/pubspec.lock
+++ b/mobile/packages/sharing/pubspec.lock
@@ -384,15 +384,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.3"
- flutter_local_authentication:
- dependency: transitive
- description:
- path: "."
- ref: "1ac346a04592a05fd75acccf2e01fa3c7e955d96"
- resolved-ref: "1ac346a04592a05fd75acccf2e01fa3c7e955d96"
- url: "https://github.com/eaceto/flutter_local_authentication"
- source: git
- version: "1.2.0"
flutter_localizations:
dependency: transitive
description: flutter
@@ -656,6 +647,13 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.3"
+ local_auth_linux:
+ dependency: transitive
+ description:
+ path: "../local_auth_linux"
+ relative: true
+ source: path
+ version: "0.1.0"
local_auth_platform_interface:
dependency: transitive
description: