This codelab introduces Multi-Factor Authentication (MFA) concepts using the cordova-plugin-rdna Cordova plugin. You'll learn how the plugin/SDK's challenge-response system works, understand different authentication flows, and master the terminology needed for implementing secure authentication.
cordova-plugin-rdna plugin installed and configuredThe RELID Plugin/SDK implements Multi-Factor Authentication through a challenge-response mechanism. This system ensures secure, step-by-step verification of user identity through multiple factors.
The MFA system works on a fundamental challenge-response pattern:
After successful Plugin/SDK initialization, the authentication process begins immediately:
Plugin/SDK Initialization Complete → getUser Challenge → MFA Flow Begins
The MFA system uses several categories of challenges:
Category | Purpose | Examples |
Identity Verification | Establish user identity |
|
Multi-Factor Verification | Verify user through multiple channels |
|
Device/Password Authentication | Authenticate using device capabilities/password verification |
|
Device Management | Handle new device scenarios |
|
Session Management | Complete authentication flows |
|
The MFA system is completely event-driven:
The RELID Plugin/SDK supports three distinct prelogin authentication flows, each designed for specific user scenarios and security requirements.
Purpose: First-time user registration and device setup
When Used:
Key Characteristics:
Flow Outcome: User gets registered successfully.
Purpose: Authenticate returning users on previously/same registered devices
When Used:
Key Characteristics:
Flow Outcome: Quick authentication leveraging device trust
Purpose: Authenticate users on devices they haven't registered before
When Used:
Key Characteristics:
Flow Outcome: User authenticated with new device added to registered devices
Each MFA challenge follows a consistent event → API response pattern. Understanding these mappings is crucial for implementing authentication flows.
Every challenge in the MFA system follows this pattern:
Plugin/SDK Challenge Event → App UI Collection → API Response → Flow Continuation
Challenge Name |
|
Event Name |
|
API Name |
|
Purpose | Collect and verify user identifier |
When Triggered | Always first challenge after initialization |
User Input | Username, email, or user identifier |
Flow Pattern:
Plugin/SDK → getUser event → App shows username input → User enters username → setUser API → Next challenge
Challenge Name |
|
Event Name |
|
API Name |
|
Purpose | Verify user through out-of-band authentication |
When Triggered | After successful user identification |
User Input | OTP code, activation code, or verification code |
Flow Pattern:
Plugin/SDK → getActivationCode event → App shows OTP input → User enters code → setActivationCode API → Next challenge
Challenge Name |
|
Event Name |
|
API Name |
|
Purpose | Traditional password-based authentication |
When Triggered | When LDA is NOT available on device |
User Input | User password |
Flow Pattern:
Plugin/SDK → getPassword event → App shows password input → User enters password → setPassword API → Authentication complete
Challenge Name |
|
Event Name |
|
API Name |
|
Purpose | Biometric or device-based authentication |
When Triggered | When LDA IS available on device |
User Input | Consent for biometric authentication |
Flow Pattern:
Plugin/SDK → getUserConsentForLDA event → App shows consent dialog → User grants consent → setUserConsentForLDA API → Biometric prompt
Challenge Name |
|
Event Name |
|
API Name |
|
Purpose | Verify legitimacy of new device |
When Triggered | During new device login flow |
User Input | Selection of verification method |
Flow Pattern:
Plugin/SDK → addNewDeviceOptions event → App handles device verification → performVerifyAuth API → Verification process
Challenge Name | N/A (Completion Event) |
Event Name |
|
API Name | NA |
Purpose | Signal successful authentication completion and user logged in |
When Triggered | After all challenges successfully completed |
User Input | None (automatic) |
Flow Pattern:
Final challenge completed → onUserLoggedIn event → App-to-user session established
Understanding key MFA terminology is essential for implementing and troubleshooting authentication flows.
A security step that the Plugin/SDK requires the user to complete. Each challenge represents a specific verification requirement.
Example: The checkuser challenge for which Plugin/SDK triggers getUser event requires the user to provide their username.
A callback sent by the Plugin/SDK to your application when a challenge needs to be addressed.
Example: The getActivationCode event indicates the Plugin/SDK needs an OTP from the user.
The method your application calls to provide the required information for a challenge.
Example: Calling setUser("john.doe") responds to the getUser challenge.
A complete sequence of challenges from start to successful authentication.
Example: Activation Flow might include: getUser → getActivationCode → getUserConsentForLDA → onUserLoggedIn
Device-based authentication using biometrics (fingerprint, face recognition) or device passcode.
Key Points:
Security method requiring users to provide two or more verification factors.
The initial registration process where a user establishes their identity and enrolls their first device.
The process of adding a device to a user's list of trusted devices.
The security relationship between a user account and a registered device, enabling streamlined future authentication.
The authenticated period between successful login and logout, managed through device tokens.
Detailed numeric error code providing specific information about what went wrong.
Generic error category for broad error classification.
Human-readable error message describing the issue and potential solutions.
Critical Timing Rules:
Correct Flow:
getUser event → setUser API → wait for next event → getActivationCode event → setActivationCode API
Incorrect Flow:
setUser API → getUser event (❌ API called before event)
getUser event → setUser API → setUser API (❌ duplicate API calls)
Congratulations! You've mastered the fundamentals of Multi-Factor Authentication (MFA) with the RELID Plugin/SDK:
✅ Challenge-Response Architecture: Understanding how Plugin/SDK events map to API responses ✅ Flow Types: Activation, Same Device Login, and New Device Login characteristics ✅ Event Integration: Extending event managers for MFA challenge handling ✅ API Patterns: Proper response patterns and error handling ✅ MFA Terminology: Essential security and technical concepts ✅ Best Practices: Timing, error handling, and implementation guidelines
You now understand:
With this foundation, you're ready for: