|
| 1 | +# Multifactor Security Authentication Using Vonage APIs and Firebase Services |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +This project is a web application demonstrating how to strengthen multifactor security authentication using the Vonage SIM Swap API and Verify v2 API, integrated with Firebase Hosting, Functions, and Firestore. The application includes a simple bank dashboard and a login form. If the SIM Swap API detects that a phone number was swapped recently, the verification code will not be sent, and additional security measures will be applied. A verification code will be sent via the Verify v2 API to authenticate the user if no recent swap is detected. |
| 6 | + |
| 7 | +## Features |
| 8 | + |
| 9 | +- A login form to enter and verify a phone number |
| 10 | +- Secure multifactor authentication using Vonage Verify v2 |
| 11 | +- SIM Swap detection to prevent compromised logins |
| 12 | +- Simple bank dashboard after successful login |
| 13 | +- Firebase Hosting for serving the application |
| 14 | +- Firebase Functions for server-side logic |
| 15 | +- Firestore for storing user data and verification status |
| 16 | + |
| 17 | +## Prerequisites |
| 18 | + |
| 19 | +- A [Vonage Developer Account](https://developer.vonage.com). |
| 20 | +- A Firebase project set up in the [Firebase Console](https://console.firebase.google.com). |
| 21 | +- Node.js and npm installed. |
| 22 | + |
| 23 | +## Getting Started |
| 24 | + |
| 25 | +1. Clone the repository and change directories |
| 26 | + ```bash |
| 27 | + git clone https://github.com/Vonage-Community/demo-sim-swap_verifyv2-javascript-multifactor_authentication-firebase.git |
| 28 | + cd https://github.com/Vonage-Community/demo-sim-swap_verifyv2-javascript-multifactor_authentication-firebase.git |
| 29 | + ``` |
| 30 | +2. Install the required packages: |
| 31 | + ```bash |
| 32 | + npm install |
| 33 | + ``` |
| 34 | + |
| 35 | +3. Move the `.env.example` file to `.env` file in the project root and include the following environment variables: |
| 36 | + ```bash |
| 37 | + mv .env.example .env |
| 38 | + ``` |
| 39 | + ```bash |
| 40 | + VONAGE_APPLICATION_ID=your_application_id |
| 41 | + VONAGE_APPLICATION_PRIVATE_KEY_PATH=/path/to/your/private.key |
| 42 | + JWT=your_jwt_token |
| 43 | + ``` |
| 44 | + |
| 45 | +4. You have the choice to set these variables: |
| 46 | + ```bash |
| 47 | + MAX_AGE=your_max_age |
| 48 | + RECIPIENT_NUMBER=your_recipient_number |
| 49 | + ``` |
| 50 | + |
| 51 | +5. Set up Firebase: |
| 52 | + - Install Firebase CLI: |
| 53 | + ```bash |
| 54 | + npm install -g firebase-tools |
| 55 | + ``` |
| 56 | + - Log in to Firebase: |
| 57 | + ```bash |
| 58 | + firebase login |
| 59 | + ``` |
| 60 | + - Initialize Firebase in your project: |
| 61 | + ```bash |
| 62 | + firebase init |
| 63 | + ``` |
| 64 | + Select `Hosting`, `Functions`, and `Firestore` when prompted. |
| 65 | + |
| 66 | +6. Deploy Firebase Functions and Hosting: |
| 67 | + ```bash |
| 68 | + firebase deploy |
| 69 | + ``` |
| 70 | + |
| 71 | +7. Run the application locally: |
| 72 | + ```bash |
| 73 | + firebase emulators:start |
| 74 | + ``` |
| 75 | + |
| 76 | +8. Launch your web browser and enter the URL: |
| 77 | + ```bash |
| 78 | + http://localhost:5000/ |
| 79 | + ``` |
| 80 | + |
| 81 | +## How It Works |
| 82 | + |
| 83 | +### SIM Swap API |
| 84 | + |
| 85 | +The application uses the Vonage SIM Swap API to check whether a given phone number has been swapped in the last few days. This protects users from attacks that exploit SIM swaps. |
| 86 | + |
| 87 | +### Verify v2 API |
| 88 | + |
| 89 | +The Verify v2 API sends a one-time code to the user's phone number for authentication. This verification code will be sent if the SIM Swap API determines that the number has not been recently swapped. |
| 90 | +
|
| 91 | +### Firebase Integration |
| 92 | +
|
| 93 | +- **Firebase Hosting:** Serves the web application. |
| 94 | +- **Firebase Functions:** Handles the server-side logic for verifying the SIM swap and sending verification codes. |
| 95 | +- **Firestore:** Stores user data and verification status, ensuring that passwords and other sensitive information are securely managed. |
| 96 | +
|
| 97 | +### Application Flow |
| 98 | +
|
| 99 | +1. The user enters their phone number on the login page. |
| 100 | +2. The SIM Swap API checks whether the number was swapped recently. |
| 101 | +3. A verification code is sent via the Verify v2 API if no swap is detected. |
| 102 | +4. After successful verification, the user can access the bank dashboard. |
| 103 | +
|
| 104 | +This setup provides a robust and scalable architecture, combining Vonage's security APIs with Firebase's comprehensive backend services. |
0 commit comments