react-native-keychain icon indicating copy to clipboard operation
react-native-keychain copied to clipboard

Display "Enter Password" option once Biometrics fail

Open kulkarniankita opened this issue 6 years ago • 10 comments

Currently, there are 2 policies:

export enum LAPolicy {
        DEVICE_PASSCODE_OR_BIOMETRICS = "AuthenticationWithBiometricsDevicePasscode",
        BIOMETRICS = "AuthenticationWithBiometrics"
    }

When I use either of those I do not get the following as a fallback screen. Is this implemented?I want to be able to show "Enter Password" once biometrics fails. Once "Enter password" is clicked, we want to go back to the screen again (dismissing the modal)

img_6535

Any help would be appreciated.

kulkarniankita avatar Jan 18 '19 16:01 kulkarniankita

@oblador is there any solution to this? this is the biggest blocking issue stopping our team from using react-native-keychain.

losh11 avatar May 11 '19 02:05 losh11

Sorry for unrelated comment but how can you guys implement TouchID and FaceID using react-native-keychain, i.e. how to open those popups using react-native-keychain APIs?

Sorry if my comment is off-topic. All helps are appreciated! Thanks in advance

npkhoa2197 avatar Jun 03 '19 15:06 npkhoa2197

@npkhoa2197 here's a tutorial which may answer your question: https://www.freecodecamp.org/news/how-to-implement-secure-biometric-authentication-on-mobile-devices-4dc518558c5c/

vasilestefirta avatar Jul 31 '19 17:07 vasilestefirta

Any news on this?

florinvasilevilsan avatar Aug 12 '19 15:08 florinvasilevilsan

The key to solving this is to set a localizedFallbackTitle on LAContext before calling evaluatePolicy:localizedReason:reply:, as described in this article.

I tried making that change locally, but couldn't find the line where the above method would be called when retrieving a password from the keychain via biometric access. If anyone could point me to it, I could try opening a PR.

Maybe this reference implementation is helpful to someone: https://github.com/mCodex/react-native-sensitive-info/blob/master/ios/RNSensitiveInfo/RNSensitiveInfo.m

richeterre avatar Nov 27 '19 09:11 richeterre

Hi @richeterre I am interested to resolve this issue as well. @kulkarniankita did not mention if this was during the setGenericPassword or getGenericPassword, I am assuming it is the getGenericPassword.

When setGenericPassword is called, it validates the user's biometrics using LAContext first and then it continues to insertKeychainEntry which calls SecAccessControlCreateWithFlags to store the record. https://github.com/oblador/react-native-keychain/blob/3954a6a9fe76108fcf5ef98480b1ad89bdeba97d/RNKeychainManager/RNKeychainManager.m#L193

When getGenericPassword is called, it calls SecItemCopyMatching which will prompt for biometric authentication if needed (determined during setGenericPassword). The biometric check is implicitly triggered during this call. https://github.com/oblador/react-native-keychain/blob/3954a6a9fe76108fcf5ef98480b1ad89bdeba97d/RNKeychainManager/RNKeychainManager.m#L323

ccjx avatar Feb 27 '20 07:02 ccjx

Update one of our team members was able to get passcode to work on their iOS device. However I am testing on Android and it still does not work

JeffreyLeeDave avatar Aug 26 '20 20:08 JeffreyLeeDave

Hi @JeffreyLeeDave . We are really interested to learn how you managed to make it work. Could you share that with us?

gabimoncha avatar Mar 20 '21 20:03 gabimoncha

Sorry for the misunderstanding, it still didn't work on Android. But it works in iOS. We didn't do anything special for it.

JeffreyLeeDave avatar Mar 22 '21 17:03 JeffreyLeeDave

@JeffreyLeeDave Any update on fallback to PIN/Pattern/Password on Android?

amolpatil15 avatar May 25 '23 07:05 amolpatil15

Implemented in https://github.com/oblador/react-native-keychain/pull/720

DorianMazur avatar Mar 09 '25 21:03 DorianMazur