The following steps demonstrate how to implement adaptive MFA with authenticator app - either at sign-in or as step-up authentication when the user performs a sensitive action in your app (e.g. making a payment).
You can choose a value for the action here which best describes what the user is doing in your app (e.g. signIn or createPayment).
Each action can have its own set of rules.
To learn more about using rules and handling different action states refer to our documentation on actions and rules.
If the action state is CHALLENGE_REQUIRED then you can present an authenticator app challenge using the Web SDK or Mobile SDK.
Custom UI
Pre-built UI
// Set token from the track responseauthsignal.setToken("eyJhbGciOiJ...");// Verify the TOTP code inputted by the userconst response = await authsignal.totp.verify({ code: "123456" });// Obtain a new tokenconst token = response.token;
// Launch the pre-built UI with the URL from the track responseconst result = await authsignal.launch(url);if (result.token) { // Obtain a new token const token = result.token;}
You can choose any value for the action here which describes the enrollment flow. This will be used to track the enrollment activity in the Authsignal Portal.
If the user is already enrolled with another authentication method, you will need to pass additional scopes when tracking this action - refer to our documentation on authenticator binding for more information.
Use the Web SDK or Mobile SDK to present a QR code which the user can scan with their authenticator app.
Custom UI
Pre-built UI
// Set token from the track responseauthsignal.setToken("eyJhbGciOiJ...");const response = await authsignal.totp.enroll();if (response.data) { const uri = response.data.uri; // Convert to QR code const secret = response.data.secret; // Can be entered manually}
// Launch the pre-built UI with the URL from the track responseconst result = await authsignal.launch(url);