I want to store user credentials securely in the iOS Keychain, but I only want the user to be able to use their fingerprint to retrieve the Keychain item. Is there a workflow for calling the Touch ID sensor to retrieve Keychain items with the ability to dismiss the passcode unlock or without falling back to the passcode at all?
I have implemented the methods defined in the WWDC session on Touch ID and Keychain, but I do not want to fall back on the device passcode like they do in their demo. I want the user to sign in traditionally once the fingerprint scan has failed.
Set the Face ID Usage Description plist file. Without this key, the system won't allow your app to use Face ID. The value for this key is a string that the system presents to the user the first time your app attempts to use Face ID.
iOS biometrics authentication: Allows you to authenticate when accessing your account from a specific iOS device, using that device's built-in biometrics, through Touch ID or Face ID. You can only sign on to your account from the same device with which you want to authenticate.
@kishikawa-katsumi is right, in iOS 8 there is no way to disable passcode fallback. The kSecAccessControlUserPresence
access control flag makes an item accessible after either Touch ID or Passcode authentication succeeds and it even doesn't require Touch ID to be available.
But this has been improved in iOS 9. Two Touch ID-related flags, kSecAccessControlTouchIDAny
and kSecAccessControlTouchIDCurrentSet
, have been added.
So, you need to use either of these two flags when creating access control object for Keychain item (with SecAccessControlCreateWithFlags
function) and assign that object to kSecAttrAccessControl
attribute when adding the item with SecItemAdd
function.
There is an example from Apple that demonstrates this; see addTouchIDItemAsync
method. Also, see this post for an overview of other security-related changes in iOS 9.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With