Authentication
Using the authentication operation, you can verify the identity of the user using an already registered authenticator.
To do an authentication operation, configure and initialize the SDK to obtain a MobileAuthenticationClient java, swift, objc, flutter, react native.
Depending on the use case, there are two types of authentication: in-app authentication and out-of-band authentication.
For more information, see Authentication.
In-app authentication
For the application to trigger the authentication, provide the name of the user to authenticate to an Authentication java, swift, objc, flutter, react native, and trigger an in-app authentication.
In Authentication Cloud, the name refers to the technical username, specifically the userId attribute of the Authentication Cloud API.
The LocalData.accounts java, swift, objc, flutter, react native method retrieves the registered accounts, and the Account.username() java, swift, objc, flutter, react native method retrieves the (technical) username of each account, which should be used for authentication instead of the login identifier (e.g., the user`s email address).
Provide an authenticator selector, which returns the authenticator to be used.
Depending on the authenticator used to authenticate, provide any of the corresponding user verifiers: PIN user verifier, password user verifier, biometric user verifier, device passcode user verifier, or fingerprint user verifier.
- Android/Kotlin
- Android/Java
- iOS/Swift
- iOS/Objective-C
- Flutter/Dart
- React Native/TypeScript
Out-of-band authentication
When the authentication is initiated in another device or application, the information required to process the operation is transmitted through a QR code or a link. An example of out-of-band authentication is the case where the user wants to do a bank transfer using a web application in a laptop, and the server sends a push notification to the application asking for authentication.
The out-of-band authentication is done in three phases:
- The payload obtained from the QR code or the link is provided to an
OutOfBandPayloadDecodejava, swift, objc, flutter, react native to obtain anOutOfBandPayloadjava, swift, objc, flutter, react native object. The payload to be provided is of type:
{
"nma_data" : {
"token" : "b4b07559-f934-4597-a1c5-44d89f691e8f",
"redeem_url" : "https://fido.siven.ch/nevisfido/token/redeem/authentication"
},
"nma_data_content_type" : "application/json",
"nma_data_version" : "1"
}
For more information on how to obtain the OutOfBandPayload, see Obtain an out-of-band payload.
Provide the
OutOfBandPayloadto anOutOfBandOperationjava, swift, objc, flutter, react native. When building theOutOfBandOperation, invoke theOutOfBandOperation.onAuthenticationmethod with an object taking anOutOfBandAuthentication.Invoke
OutOfBandOperation.execute. If the provided payload is successfully redeemed in the server, and it corresponds to an authentication, the object provided inOutOfBandOperation.onAuthenticationis invoked with anOutOfBandAuthenticationjava, swift, objc, flutter, react native.Provide an authenticator selector, and the required user verifiers to the
OutOfBandAuthentication.Invoke
OutOfBandAuthentication.executeto continue with the operation.
- Android/Kotlin
- Android/Java
- iOS/Swift
- iOS/Objective-C
- Flutter/Dart
- React Native/TypeScript
Usernameless authentication
You can start an out-of-band authentication without a username in the initial request. In this scenario, the operation allows to authenticate with different accounts. To support the scenario, provide an Account Selector.
If you do not need to support usernameless authentication, or if your application only supports one account, you do not need to provide the AccountSelector.
Transaction confirmation
There are cases when specific information is to be presented to the user during the user verification process, known as transaction confirmation in the FIDO UAF protocol.
In case of transaction confirmation, the AuthenticatorSelectionContext java, swift, objc, flutter, react native and the AccountSelectionContext java, swift, objc, flutter, react native contain a byte array with the transaction information. The byte array corresponds to the content attribute.
- Android/Kotlin
- Android/Java
- iOS/Swift
- iOS/Objective-C
- Flutter/Dart
- React Native/TypeScript
Lifecycle
- The authentication is started by calling the
executemethod. - In case of out-of-band authentication, where an Account Selector is to be provided, the SDK invokes the account selector. If the
AccountSelectionContextcontains transaction confirmation information, the contents of the transaction confirmation are presented to the user for validation. - The SDK invokes the Authenticator Selector. If the
AuthenticatorSelectionContextcontains transaction confirmation information and the contents are not presented previously, the contents of the transaction confirmation are presented to the user for validation. Depending on the selected authenticator, the SDK does the following:- Invoke the PIN user verifier, if PIN is selected.
- Invoke the password user verifier, if password is selected.
- Invoke the biometric user verifier, if a biometric authenticator (biometric authenticator in Android, FaceID or TouchID authenticator in iOS) is selected.
- Invoke the device passcode user verifier, if the device passcode authenticator is selected.
- Invoke the fingerprint user verifier, only applicable when running on an Android device, when the fingerprint authenticator is selected.
- When the operation is completed, the SDK does the following:
- Invoke the object provided to
Authentication.onSuccessjava, swift, objc, flutter, react native, if the operation is completed successfully. - Invoke the object provided to
Authentication.onErrorjava, swift, objc, flutter, react native with the error, if the operation is completed with an error.
- Invoke the object provided to
In-app authentication
Out-of-band authentication
Account selector
To support usernameless authentication and multiple accounts, define an AccountSelector java, swift, objc, flutter, react native, and if using the OutOfBandAuthentication.accountSelector java, swift, objc, flutter, react native method.
Select an account
The AccountSelector is called by the SDK to select an account used for the out-of-band authentication. It is the responsibility of the application to decide whether to ask the user to perform the selection, or to do it directly without user intervention.
- The user initiates an action that requires to select an account, like scanning an authentication QR code.
- The application invokes
Operationsjava, swift, objc, flutter, react native to build the operation. The application provides theAccountSelectorto the operation built. - The SDK calls the
AccountSelector.selectAccountjava, swift, objc, flutter, react native method. TheAccountSelectionContextjava, swift, objc, flutter, react native contains a list of accounts and authenticator objects to identify which accounts can be used with which authenticator. - The application shows the list of available accounts to the user.
- The user selects an account.
- The application provides the username of the account invoking the
AccountSelectionHandler.usernamejava, swift, objc, flutter, react native method.
The SDK can now continue the out-of-band authentication using the selected account.
Authenticator selector
The Nevis Mobile Authentication SDK needs to know which is the authenticator used for the operation. The developer has to provide an AuthenticatorSelector java, swift, objc, flutter, react native when building the operation.
It is very important that the authenticator selector performs the necessary checks to determine whether an authenticator is "usable" or not, otherwise the operation will fail.
Checks that need to be done are:
- Is the authenticator policy compliant java, swift, objc, flutter, react native
- Is the authenticator supported by the mobile device hardware
- Is the authenticator not registered (registration) or registered (authentication) for the given user
The JavaDoc contains example code of these checks.
Select an authenticator
The AuthenticatorSelector is called by the SDK to select an authenticator used for the operation. It is the responsibility of the application to decide whether to ask the user to perform the selection, or to do it directly without user intervention.
- The user initiates an action that requires to select an authenticator, like registration or authentication.
- The application invokes
Operationsjava, swift, objc, flutter, react native to build the operation. The application provides theAuthenticatorSelectorto the operation being built. - The SDK calls the
AuthenticatorSelector.selectAuthenticatorjava, swift, objc, flutter, react native method. TheAuthenticatorSelectionContextjava, swift, objc, flutter, react native contains a list of authenticator objects, including AAIDs, which uniquely identify each authenticator. - The application shows the list of available authenticators to the user.
- The user selects an authenticator.
- The application provides the AAID of the authenticator invoking the
AuthenticatorSelectionHandler.aaidjava, swift, objc, flutter, react native method.
The SDK can now continue the operation started by using the selected authenticator.
PIN user verifier
When authentication with PIN is required, the developer has to provide a PinUserVerifier java, swift, objc, flutter, react native when building the operation. The PinUserVerifier is in charge of displaying a user interface asking the user to provide the PIN and to display the recoverable errors during authentication, for example, if the user provided an invalid PIN.
PIN user verification
The PinUserVerifier is called by the SDK to ask the user to provide a PIN.
- The SDK calls the
PinUserVerifier.verifyPinjava, swift, objc, flutter, react native method. - The application asks the user to provide a PIN. For example, the application displays a textbox where the user provides a PIN.
- The user provides the PIN.
- The application provides the PIN invoking the
PinUserVerificationHandler.verifyPinjava, swift, objc, flutter, react native method. - The SDK validates whether the provided PIN is valid.
- If the provided PIN is not valid, and the PIN authenticator is not locked, the SDK invokes
PinUserVerifier.verifyPinagain and thePinUserVerificationContextjava, swift, objc, flutter, react native contains a recoverable error. - If the provided PIN is not valid, and too many failed attempts occurred, the PIN authenticator is locked, and the operation fails. The object managing the error provided in the
onErrormethod when building the operation is invoked. For more information on PIN lockout, see Brute force attack prevention. - On Android, Flutter and React Native, if the provided credentials are valid, the
PinUserVerifier.onValidCredentialsProvidedjava, flutter, react native method is invoked.
After certain number of failed attempts, the PIN authenticator will enter the cool-down mode. When in cool-down mode, providing a PIN (valid or invalid) will be ignored, and the SDK will invoke again PinUserVerifier.verifyPin without changing the number of remaining retries. This implies that the PIN authenticator cannot be locked when it is in cool-down mode.
Thus, providing a PIN when in cool-down mode will just generate unnecessary processing, and it is recommended to avoid it.
Password user verifier
When authentication with password is required, the developer has to provide a PasswordUserVerifier java, swift, objc, flutter, react-native when building the operation. The PasswordUserVerifier is in charge of displaying a user interface asking the user to provide the password and to display the recoverable errors during authentication, for example, if the user provided an invalid password.
Password user verification
The PasswordUserVerifier is called by the SDK to ask the user to provide a password.
- The SDK calls the
PasswordUserVerifier.verifyPasswordjava, swift, objc, flutter, react-native method. - The application asks the user to provide a password. For example, the application displays a textbox where the user provides a password.
- The user provides the password.
- The application provides the password invoking the
PasswordUserVerificationHandler.verifyPasswordjava, swift, objc, flutter, react-native method. - The SDK validates whether the provided password is valid.
- If the provided password is not valid, and the password authenticator is not locked, the SDK invokes
PasswordUserVerifier.verifyPasswordagain and thePasswordUserVerificationContextjava, swift, objc, flutter, react-native contains a recoverable error. - If the provided password is not valid, and too many failed attempts occurred, the password authenticator is locked, and the operation fails. The object managing the error provided in the
onErrormethod when building the operation is invoked. For more information on password lockout, see Brute force attack prevention. - On Android, Flutter and React Native, if the provided credentials are valid, the
PasswordUserVerifier.onValidCredentialsProvidedjava, flutter, react-native method is invoked.
After certain number of failed attempts, the password authenticator will enter the cool-down mode. When in cool-down mode, providing a password (valid or invalid) will be ignored, and the SDK will invoke again PasswordUserVerifier.verifyPassword without changing the number of remaining retries. This implies that the password authenticator cannot be locked when it is in cool-down mode.
Thus, providing a password when in cool-down mode will just generate unnecessary processing, and it is recommended to avoid it.
Biometric user verifier
The biometric authenticator is specific to Android devices. For iOS please refer to the FaceID or TouchID authenticator.
When authentication using the biometric authenticator is required, the developer has to provide a BiometricUserVerifier java, swift, objc, flutter, react native when building the operation. The BiometricUserVerifier does not need to implement the user interface asking for biometric credentials, as this is handled by the SDK.
Biometric user verification
The BiometricUserVerifier is called by the SDK to ask the user to provide fingerprint credentials.
- The SDK calls the
BiometricUserVerifier.verifyBiometricjava, swift, objc, flutter, react native method. - On Android, Flutter and React Native, the application invokes
BiometricUserVerificationHandler.listenForOsCredentialsjava, flutter, react native so that the SDK starts listening for biometric credentials. - On iOS, the application invokes the
BiometricUserVerificationHandler.verifyswift, objc method. - The SDK displays a user interface asking the user to provide credentials.
- The user provides biometric credentials.
- The operating system validates the provided credentials.
- If the provided biometric credentials are not valid, the operating system displays an error to inform the user. If supported by the OS version and enabled during registration, it also proposes the user to provide device credentials as fallback: PIN, gestures, or password.
- If the provided biometric information is not valid, and too many failed attempts occurred, then the operation fails, and the object managing the error provided in the
onErrormethod when building the operation is invoked. - On Android, Flutter and React Native, if the provided credentials are valid, the
BiometricUserVerifier.onValidCredentialsProvidedjava, flutter, react native method is invoked.
Biometric prompt customization
On Android the biometric prompt shown to users is customizable by providing a BiometricPromptOptions java, flutter, react native object when invoking the BiometricUserVerificationHandler.listenForOsCredentials java, flutter, react native method. The BiometricPromptOptions allows you to set properties such as the prompt title, description, and the text for the cancel button. This enables you to tailor the user experience to your application's branding and requirements.
- Android/Kotlin
- Android/Java
- Flutter/Dart
- React Native/TypeScript
val options = BiometricPromptOptions.builder()
.title("Verification")
.description("Please verify your identity")
.cancelButtonText("Cancel")
.build()
handler.listenForOsCredentials(options)
BiometricPromptOptions options = BiometricPromptOptions.Builder()
.title("Verification")
.description("Please verify your identity")
.cancelButtonText("Cancel")
.build();
handler.listenForOsCredentials(options);
final options = BiometricPromptOptions(
title: "Verification",
description: "Please verify your identity",
cancelButtonText: "Cancel",
)
await handler.listenForOsCredentials(options)
const options = BiometricPromptOptions.create(
"Verification",
"Please verify your identity",
"Cancel");
await handler.listenForOsCredentials(options)
To customize biometric prompt messages on iOS (including Flutter and React Native apps), add a string catalog or a Localizable.strings file to your iOS project if it does not exist. Then, define the following keys to control the prompt messages:
| Key | Default Value |
|---|---|
face_recognition_authenticator_register_operation_prompt_message | Use Face ID to register for Mobile Authentication |
fingerprint_authenticator_register_operation_prompt_message | Provide your fingerprint to register for Mobile Authentication |
face_recognition_authenticator_authenticate_operation_prompt_message | Authenticate using Face ID |
fingerprint_authenticator_authenticate_operation_prompt_message | Authenticate with your fingerprint |
Device passcode user verifier
When authentication using the device passcode authenticator is required, the developer has to provide a DevicePasscodeUserVerifier java, swift, objc, flutter, react native when building the operation. The DevicePasscodeUserVerifier does not need to implement the user interface asking for device passcode credentials, as this is handled by the SDK.
Device passcode user verification
The DevicePasscodeUserVerifier is called by the SDK to ask the user to provide device passcode credentials.
- The SDK calls the
DevicePasscodeUserVerifier.verifyDevicePasscodejava, swift, objc, flutter, react native method. - On Android, Flutter and React Native, the application invokes
DevicePasscodeUserVerificationHandler.listenForOsCredentialsjava, flutter, react native so that the SDK starts listening for device passcode credentials. - On iOS, the application invokes the
DevicePasscodeUserVerificationHandler.verifyswift, objc method. - The SDK invokes the operating system to display a user interface asking the user to provide credentials.
- The user provides device passcode credentials.
- The operating system validates the provided credentials.
- If the provided device passcode credentials are not valid, the operating system displays an error to inform the user.
- If the provided device passcode information is not valid, and too many failed attempts occurred, then the operation fails, and the object managing the error provided in the
onErrormethod when building the operation is invoked. - On Android, Flutter and React Native, if the provided credentials are valid, the
DevicePasscodeUserVerifier.onValidCredentialsProvidedjava, flutter, react native method is invoked.
Device Passcode prompt customization
On Android the device passcode prompt shown to users is customizable by providing a DevicePasscodePromptOptions java, flutter, react native object when invoking the DevicePasscodeUserVerificationHandler.listenForOsCredentials java, flutter, react native method. The DevicePasscodePromptOptions allows you to set the prompt title and the description. This enables you to tailor the user experience to your application's branding and requirements.
- Android/Kotlin
- Android/Java
- Flutter/Dart
- React Native/TypeScript
val options = DevicePasscodePromptOptions.builder()
.title("Verification")
.description("Please verify your identity")
.build()
handler.listenForOsCredentials(options)
DevicePasscodePromptOptions options = DevicePasscodePromptOptions.Builder()
.title("Verification")
.description("Please verify your identity")
.build();
handler.listenForOsCredentials(options);
final options = DevicePasscodePromptOptions(
title: "Verification",
description: "Please verify your identity",
)
await handler.listenForOsCredentials(options)
const options = DevicePasscodePromptOptions.create(
"Verification",
"Please verify your identity");
await handler.listenForOsCredentials(options)
To customize device passcode prompt message on iOS (including Flutter and React Native apps), add a string catalog or a Localizable.strings file to your iOS project if it does not exist. Then, define the following keys to control the prompt message:
| Key | Default value |
|---|---|
device_passcode_authenticator_register_operation_prompt_message | Authenticate with Device Passcode |
device_passcode_authenticator_authenticate_operation_prompt_message | Authenticate using device Passcode |
Fingerprint user verifier
The fingerprint authenticator is supported only on Android devices. The SDK supports the fingerprint authenticator to handle older Android OS versions that do not support the biometric authentication. If the biometric authenticator is supported by the operating system, we recommend to use that authenticator, and not to allow class 2 sensors for maximum security. This means that only the fingerprint will be available as an authentication method of the biometric authenticator.
When authentication with fingerprint is required, the developer has to provide a FingerprintUserVerifier java, flutter, react native when building the operation. The FingerprintUserVerifier is in charge of displaying a user interface asking the user to provide fingerprints, and to display the recoverable errors during authentication. For example, if the user moved the finger too quickly.
Fingerprint user verification
The FingerprintUserVerifier is called by the SDK to ask the user to provide fingerprint credentials.
- The SDK calls the
FingerprintUserVerifier.verifyFingerprintjava, flutter, react native method. - The application invokes
FingerprintUserVerificationHandler.listenForOsCredentialsjava, flutter, react native so that the SDK starts listening for fingerprint credentials. The SDK does not automatically display relevant UI. - The application asks the user to provide fingerprint credentials, for example, by displaying a screen with an image of a fingerprint.
- The user provides fingerprint credentials.
- The SDK validates that the provided fingerprints are valid.
- If the provided fingerprints are not valid, the SDK invokes
FingerprintUserVerifier.verifyFingerprintagain, and theFingerprintUserVerificationContextjava, flutter, react native contains a recoverable error. - If the provided fingerprints are not valid, and too many failed attempts occurred, then the operation fails and the object managing the error that was provided in the
onErrormethod when building the operation is invoked. - If the provided credentials are valid, the
FingerprintUserVerifier.onValidCredentialsProvidedjava, flutter, react native method is invoked.