DaaS / Products / Complete User Authentication with 2FA

Complete User Authentication with 2FA

Configure IDaaS as the central authentication platform for social logins and SSO, then integrate Twilio Verify API to deliver SMS-based two-factor authentication for enhanced security.

Products involved

Scenario

Use this workflow when you need Alibaba Cloud IDaaS to centralize social logins and enterprise SSO, but require carrier-grade SMS two-factor authentication that exceeds native IDaaS capabilities. By routing IDaaS authentication events to Twilio Verify via a custom webhook, you maintain a unified identity directory while leveraging Twilio’s global SMS delivery and fraud protection.

Integration steps

  1. Configure IDaaS Identity Sources: In the IDaaS console, navigate to Authentication > Identity Providers. Enable your social logins (e.g., Google, WeChat) and set the callback URL to your application.
  2. Select 2FA Routing Path: Under Security > Authentication Policies, create a new policy. Choose the Custom Webhook routing option for secondary authentication and point it to your backend endpoint: https://your-api.example.com/idaas/2fa-trigger.
  3. Initialize Twilio Verify Service: Run twilio api:verify:v2:services:create --friendly-name "App2FA" to generate a Service SID (e.g., VAxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx).
  4. Trigger SMS Verification: When IDaaS calls your webhook, extract the user’s phone number. Call Twilio Verify to dispatch the OTP:
  5. ``bash curl -X POST "https://verify.twilio.com/v2/Services/VAxxx/Verifications" \ -u "ACxxx:your_auth_token" \ -d "To=+15551234567" -d "Channel=sms" ``

  6. Validate OTP & Resume Flow: Collect the user’s 6-digit code and verify it:
  7. ``bash curl -X POST "https://verify.twilio.com/v2/Services/VAxxx/VerificationCheck" \ -u "ACxxx:your_auth_token" \ -d "To=+15551234567" -d "Code=123456" ``

  8. Finalize IDaaS Session: If Twilio returns "status": "approved", respond to the IDaaS webhook with {"status": "success", "auth_request_id": "<original_id>"}. IDaaS completes the SSO handshake and issues the final JWT.

Architecture

IDaaS acts as the primary identity orchestrator, handling social/SSO credential validation and session state. Upon successful primary login, IDaaS pauses the flow and invokes your backend webhook. The backend bridges to Twilio Verify API, which manages OTP generation, carrier routing, and validation. Once Twilio confirms verification, the backend signals IDaaS to resume and mint the final access token.

Prerequisites

Common pitfalls

Typical questions