Member-only story
How to Implement Face ID, Touch ID, and LocalAuthentication in Swift
Convenience and security
Difficulty: Beginner | Easy | Normal | Challenging
Prerequisites
- To be able to produce a “Hello, World!” iOS application (guide)
This project (to begin with) uses my HTTPManager and Keychain and my method of building URLS.
Terminology
- Face ID: Secure authentication using the TrueDepth camera on supporting devices
LocalAuthentication
: a framework to authenticate users using biometrics or a passphrase- Touch ID: A fingerprint identity sensor
Making a Server Call With Touch ID/Face ID (Biometrics)
This project is about using biometrics to make a server call where necessary (that is, it isn’t about a second-degree authentication). We assume here that the token would be required for later calls to the server and needs to be stored on the device.
When a user logs in to the app (for the first time) the token can be called in the keychain.
When the user subsequently logs into the app, the user can use the biometric functions on their device to authenticate themselves and move straight into the app. Since we have the token, this can be used later in the user session.
The Initial Project
The initial project uses a way of building URLs that I’ve previously documented. It follows a registration and login process using https://reqres.in which you might test with Postman
(here’s a tutorial on how to do that).
Other than that, the project is simply designed to find out if you have a token.
The only user that will be registered and logged in is eve.holt@reqres.in with the password “pistol”.
Get out clause: This is meant to be a simple demo project, so I’ve kept all the extras away from it!
Implementation
Note: Many files in this project need to import LocalAuthentication
to allow use of the biometric functions in iOS.