Skip to content

Added Local Authentication support. - #3682

Closed
bitmvk wants to merge 18 commits into
flet-dev:mainfrom
bitmvk:auth
Closed

Added Local Authentication support.#3682
bitmvk wants to merge 18 commits into
flet-dev:mainfrom
bitmvk:auth

Conversation

@bitmvk

@bitmvk bitmvk commented Jul 20, 2024

Copy link
Copy Markdown
Contributor

Description

Added support for local authentication using https://pub.dev/packages/local_auth.
Supporting Platforms: android, ios, windows.

Local authentication uses the registered password (or pin or pattern) and biometrics (Fingerprint and Face on Android, FaceId on IOS, not supported on windows) to verify if the actual owner of the device or someone who has access to the device is the one accessing the sensitive data stored in the app.

Example use cases: bank app, password manager

Fixes #3192

Test Code

import flet as ft


def main(page: ft.Page):
    auth = ft.LocalAuthentication()

    def on_click(e):
        print(
            auth.authenticate(
                title="title", biometricsOnly=False, useErrorDialogs=True
            )
        )

    page.overlay.append(auth)
    page.add(ft.SafeArea(content=ft.TextButton(text="authenticate", on_click=on_click)))


ft.app(main)

title: title to be displayed when prompted to authenticate

biometricsOnly: gives the user option to authenticate using only biometrics(NOT SUPPORTED ON WINDOWS)

useErrorDialogs: Whether the system will attempt to handle user-fixable issues encountered while authenticating. For instance, if a fingerprint reader exists on the device but there's no fingerprint registered, the plugin might attempt to take the user to settings to add one.

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

Checklist:

  • I signed the CLA.
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • New and existing tests pass locally with my changes
  • I have made corresponding changes to the documentation (if applicable)

Screenshots (if applicable):

Additional details

Summary by Sourcery

This pull request introduces local authentication support across Android, iOS, and Windows platforms using the local_auth package. It includes updates to the Android client, new Dart and Python files for the LocalAuthentication control, and corresponding documentation.

  • New Features:
    • Added support for local authentication using the local_auth package, enabling authentication via password, PIN, pattern, and biometrics on Android, iOS, and Windows.
  • Enhancements:
    • Updated MainActivity in the Android client to extend FlutterFragmentActivity instead of FlutterActivity.
  • Documentation:
    • Added documentation for the new LocalAuthentication control, including usage examples and configuration options.

@sourcery-ai

sourcery-ai Bot commented Jul 20, 2024

Copy link
Copy Markdown
Contributor

Reviewer's Guide by Sourcery

This pull request introduces local authentication support across Android, iOS, and Windows platforms using the local_auth package. It includes updates to the Android client, new Dart and Python files for the LocalAuthentication control, and initial documentation for the new feature.

File-Level Changes

Files Changes
client/android/app/src/main/kotlin/com/appveyor/flet/MainActivity.kt
client/lib/main.dart
client/windows/flutter/generated_plugin_registrant.cc
client/pubspec.yaml
client/windows/flutter/generated_plugins.cmake
Integrated local authentication support by updating the Android client, adding necessary imports and initializations in the main Dart file, and registering the local_auth plugin for Windows.
sdk/python/packages/flet-core/src/flet_core/local_authentication.py
packages/flet_local_auth/lib/src/local_auth.dart
packages/flet_local_auth/pubspec.yaml
packages/flet_local_auth/lib/src/create_control.dart
packages/flet_local_auth/analysis_options.yaml
packages/flet_local_auth/CHANGELOG.md
packages/flet_local_auth/README.md
packages/flet_local_auth/lib/flet_local_auth.dart
Added new files for the flet_local_auth package, including implementation, control creation, and documentation.

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @vv2006-mc - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 5 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

Comment thread sdk/python/packages/flet-core/src/flet_core/local_authentication.py Outdated
Comment thread sdk/python/packages/flet-core/src/flet_core/local_authentication.py Outdated
Comment thread packages/flet_local_auth/lib/src/local_auth.dart Outdated
Comment thread packages/flet_local_auth/lib/src/local_auth.dart Outdated
Comment thread packages/flet_local_auth/lib/src/create_control.dart
@bitmvk

bitmvk commented Jul 20, 2024

Copy link
Copy Markdown
Contributor Author

@sourcery-ai review

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @vv2006-mc - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 8 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟡 Documentation: 1 issue found

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

Comment thread sdk/python/packages/flet-core/src/flet_core/local_authentication.py Outdated
Comment thread sdk/python/packages/flet-core/src/flet_core/local_authentication.py Outdated
Comment thread sdk/python/packages/flet-core/src/flet_core/local_authentication.py Outdated
Comment thread packages/flet_local_auth/lib/src/local_auth.dart Outdated
Comment thread packages/flet_local_auth/lib/src/local_auth.dart Outdated
Comment thread packages/flet_local_auth/lib/src/local_auth.dart Outdated
Comment thread packages/flet_local_auth/lib/src/local_auth.dart Outdated
Comment thread packages/flet_local_auth/lib/src/create_control.dart
Comment thread packages/flet_local_auth/README.md Outdated
bitmvk and others added 3 commits July 21, 2024 01:36
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
@ndonkoHenri

Copy link
Copy Markdown
Contributor

@vv2006-mc Thanks for your contribution!
Let know when this PR is ready to be reviewed.

@bitmvk

bitmvk commented Jul 25, 2024

Copy link
Copy Markdown
Contributor Author

@ndonkoHenri the integration for Android, iOS, and Windows is completed. I am currently searching for ways to integrate with macOS and Linux.

I will notify you when integrating macOS and Linux is completed.

@CLAassistant

CLAassistant commented Jul 25, 2024

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@baseplate-admin baseplate-admin left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi one small nit

@bitmvk

bitmvk commented Jul 26, 2024

Copy link
Copy Markdown
Contributor Author

@ndonkoHenri if you have access to physical linux machine, can you please check if the linux implementation works?
It worked on a virtual machine(Fedora), but I would like to see it work on a physical linux machine.

@ndonkoHenri

Copy link
Copy Markdown
Contributor

I don't have one, sorry.

@bitmvk

bitmvk commented Jul 26, 2024

Copy link
Copy Markdown
Contributor Author

@ndonkoHenri os what do we do now?
I don't know anyone who has a linux.....
can this be merged without checking on a physical machine?

@ndonkoHenri

Copy link
Copy Markdown
Contributor

If you are done I could start reviewing and testing with my devices.
If one of the reviewers has Linux it will be tested there too.
@FeodorFitsner, you have one?

@bitmvk

bitmvk commented Jul 26, 2024

Copy link
Copy Markdown
Contributor Author

@ndonkoHenri For linux I only tested in a virtual machine so I am not that sure if it will work properly.
Except that, the control is completed and is ready for the review.

@ndonkoHenri
ndonkoHenri self-requested a review July 26, 2024 18:06
Comment thread packages/flet_local_auth/lib/src/local_auth.dart Outdated
Comment thread packages/flet_local_auth/lib/src/local_auth.dart Outdated
Comment thread packages/flet_local_auth/lib/src/local_auth.dart
Comment thread packages/flet_local_auth/lib/src/local_auth.dart
@bitmvk

bitmvk commented Aug 7, 2024

Copy link
Copy Markdown
Contributor Author

@ndonkoHenri I can't figure out what went wrong can you help me a bit when you are free?

And sorry for the force-push my computer crashed while I was running a command in git and somehow pushed that.

@bitmvk bitmvk closed this Aug 31, 2024
@bitmvk
bitmvk deleted the auth branch August 31, 2024 09:04
@ndonkoHenri

ndonkoHenri commented Aug 31, 2024

Copy link
Copy Markdown
Contributor

Why close @Vivekananda-Mullangi ?
Sorry for not responding. I was focusing on the 0.24.0 release.

@bitmvk

bitmvk commented Aug 31, 2024

Copy link
Copy Markdown
Contributor Author

I am trying to make a better version @ndonkoHenri, I will open an other pr with that when it is done.

This approach is using python to provide support for linux, but there is a way to do that directly from flutter by using invokeMethod. I got it to work partially. It will take me some time to get it working. that will make the app more streamline and will give the developer more options to work with.

And local_auth now directly supports macOS so no need for that to be integrated seperately too.

@ndonkoHenri

Copy link
Copy Markdown
Contributor

Awesome! 🔥
Let know if you need assistance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Local Authentication

4 participants