How Do I Force An iOS TouchID To Re-Authorize After Each Access, or Check If It is Unlocked?

652 views Asked by At

OK. I suspect I just need to be directed to the appropriate "M" for "RTFM." I'm not new to iOS, but fairly new to keychain use. I am using a good keychain wrapper called "FXKeychain."

I have an app that includes a login, with a password stored in the default keychain.

I use TouchID to validate the user and fill in the password.

In order to do this, I display a "thumbprint" button, with an IBAction handler that runs the standard code:

self.s_authenticationContext.evaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, localizedReason: "Yo. Gimmie ur thumb.", reply: self.touchIDCallback)

The issue is, that once it is unlocked, subsequent touches of the button, using the above, skip the alert, and simply fall through.

This is an issue because the same button is displayed, even after the user is validated. I'd like to either:

  1. Re-lock after entering the password, so the user must re-authenticate each time (preferred), or
  2. Display a different button image that indicates the thumbprint is no longer necessary.

That means that I need to:

  1. Find a way to re-lock the TouchID, or
  2. Find out if the user is unlocked.

Any ideas?

Thanks!

1

There are 1 answers

1
Paulw11 On BEST ANSWER

It is your authentication context rather than the keychain that is 'unlocked'. If you allocate a new authentication context before calling evaluatePolicy then the touchID dialog will be shown again.

You can, however, actually use touchID to authenticate access to a keychain item directly. The Apple sample code demonstrates how to do this - https://developer.apple.com/library/ios/samplecode/KeychainTouchID/Introduction/Intro.html#//apple_ref/doc/uid/TP40014530-Intro-DontLinkElementID_2