FreakyAli / Plugin.Maui.Biometric

A biometric plugin for .NET MAUI
MIT License
106 stars 11 forks source link

How to use choose biometric type i.e. fingerprint or facial biometrics on Android #4

Closed Kaayo closed 5 months ago

Kaayo commented 6 months ago

Hello, I downloaded the test application from repository: https://github.com/jfversluis/MauiBiometricPluginSample and it works great authenticating using your finger. But face authentication isn't working. The phone I use for the tests is a Xiaomi Mi M9T that allows biometrics using the finger and face. How do I choose which biometrics I want to use? Grateful

FreakyAli commented 6 months ago

So face recognition on Android was unsupported until quite recently, it is now supported on Android 10+ and I just got the documentation for it a couple days ago, for the time being this is a feature which is in progress, I am planning to add this asap but it might take some time, hope you don't mind.

More information on this here https://source.android.com/docs/security/features/biometric/face-authentication

FreakyAli commented 6 months ago

@Kaayo When you try to use Weak Authentication with Android does it allow you to use Face recognition can you please confirm?

After going through this thread, i feel you should be able to https://issuetracker.google.com/issues/111315641?pli=1

Kaayo commented 6 months ago

@Kaayo When you try to use Weak Authentication with Android does it allow you to use Face recognition can you please confirm?

As soon as possible I will perform the test and let you know here.

if you need help testing on the Android platform in the future, I'm at your disposal. This plugin is very requested in my projects and I believe it will help the community as a whole. Go on.

FreakyAli commented 6 months ago

I just verified and it is working with Weak Auth, the only issue is you cannot have a fingerprint enrolled, if you want it to instead choose from face recognition/fingerprint, you need to use the old deprecated APIs from FingerprintManager... https://issuetracker.google.com/issues/111315641?pli=1

I need suggestions here do you think we should implement those deprecated APIs for this option or wait for Google to add this option to their latest APIs?

Also once you test don't close this bug, GetAuthenticationStatusAsync needs to fix a bug related to this and this issue can be a tracker for this or may be i will raise another bug for it idk for now

image

Kaayo commented 6 months ago

I need suggestions here do you think we should implement those deprecated APIs for this option or wait for Google to add this option to their latest APIs?

I think that to meet the demand of all developers, including mine currently.

It is better to make the old APIs available (Facial and Finger) and in parallel work and wait for the new Google APIs.

So we don't force anyone to wait to use the plugin, but it's important to let us know in the repository that in the future in the new versions a new way of implementing the library in projects may be addressed, which may cause breaks in the application code, and developers they should update their codebases.

FreakyAli commented 6 months ago

It is better to make the old APIs available (Facial and Finger) and in parallel work and wait for the new Google APIs.

Okay, I will do some RnD and see if we can do this and how exactly would it be done, If possible i will try to add this feature over the weekend

FreakyAli commented 6 months ago

@Kaayo Since the code that will be used in this will be a bunch of deprecated native android code, I am gonna mark it as such hope that is not a problem for you!

FreakyAli commented 6 months ago

I think we have a small problem...

Choosing between the two is not possible at all on Android, the old deprecated APIs are fingerprint only!

When I initially read the documentation, I misunderstood what it said, I thought it meant that the old APIs had a way for the developer to specifying what the user can choose to Authenticate themselves, Whereas what it is, is that when the user authenticates you know how they did it...

https://stackoverflow.com/a/59685507/7462031

FreakyAli commented 6 months ago

Even the image from the original Android studio face ID thing makes it clear, but I somehow missed it

image

https://source.android.com/docs/security/features/biometric/face-authentication

Kaayo commented 6 months ago

Uma vez que o código que será usado neste será um monte de código Android nativo preterido, vou marcá-lo como tal espero que não seja um problema para você!

For me, I would have no problem leaving the legacy API code as "deprecated".

Kaayo commented 6 months ago

I think we have a small problem...

Choosing between the two is not possible at all on Android, the old deprecated APIs are fingerprint only!

When I initially read the documentation, I misunderstood what it said, I thought it meant that the old APIs had a way for the developer to specifying what the user can choose to Authenticate themselves, Whereas what it is, is that when the user authenticates you know how they did it...

https://stackoverflow.com/a/59685507/7462031

Apparently, we're going to need to wait for Google to make some example of lower-level code available for you to adapt or we're going to maybe need help from someone who understands the lower-level code, or am I mistaken?

FreakyAli commented 6 months ago

I already understand the native code, the problem is in our previous discussion I had just checked the documentation from a very high level, as I went deep I realised what we need here is not natively possible at all

Kaayo commented 6 months ago

I already understand the native code, the problem is in our previous discussion I had just checked the documentation from a very high level, as I went deep I realised what we need here is not natively possible at all

Understand. I believe that maybe by talking to the Microsoft community they could maybe give us a direction or make some more up-to-date API available for NET CORE/MAUI. Maybe this guy can help us: https://www.youtube.com/@jfversluis, he made a video of his plugin.

FreakyAli commented 6 months ago

I don't think anyone at Microsoft can help us with this, this has nothing to do with .NET or .NET MAUI and everything to do with Android native, the only people that can do anything here are the folks at Google and I don't think they wanna do anything about it especially since the bug has been open with them since 2018 and they still have not done anything for this in the last 6 or so years.

Kaayo commented 6 months ago

I don't think anyone at Microsoft can help us with this, this has nothing to do with .NET or .NET MAUI and everything to do with Android native, the only people that can do anything here are the folks at Google and I don't think they wanna do anything about it especially since the bug has been open with them since 2018 and they still have not done anything for this in the last 6 or so years.

Well, so that we don't end this conversation without a possible solution. I suggest opening an issue in the Android repository and linking our issue there. So at least the new devs who search for your plugin are aware and maybe some of them can help us get Google to take action. Well, I believe it, in case I'm not mistaken. that this bug you reported interferes with technologies other than .NET, such as React Native or Flutter.

FreakyAli commented 6 months ago

@Kaayo When you try to use Weak Authentication with Android does it allow you to use Face recognition can you please confirm?

After going through this thread, I feel you should be able to https://issuetracker.google.com/issues/111315641?pli=1

I have linked the bug as you can see right at the start of our conversation.

FreakyAli commented 6 months ago

For future visitors, this cannot be worked on until https://issuetracker.google.com/issues/111315641?pli=1 is fixed by google

FreakyAli commented 5 months ago

This is pinned and hence I am closing this until future updates to the google issue this is based on, comments are open just in case!