Search code examples
aws-sdkamazon-cognitotwo-factor-authenticationauthy

Cognito & Two Factor Authentication


Is there any available SDK of Twilio or Authy to use for Two Factor Authentication with Cognito?

Or What are the best practices to do User Authentication via Cognito with Two Factor Authentication?

Basically how mobile app authenticate user with Two Factor Authentication by using Cognito for Identity Management?


Solution

  • One important clarification - Cognito doesn't manage users for you. Cognito leverages public providers (facebook, google, amazon, twitter, an existing external provider...etc.) to generate AWS credentials for whatever user 'signs in'. Additionally, there isn't a native MFA mechanism in Cognito as of now.

    With that in mind, it should be possible to do it yourself, however you would need to build some additional mechanism. Say you were trying to log into facebook - the common flow would be to:

    1) open up app 2) click sign in button 3) sign in to facebook 4) app validates login with facebook, gets generated token 5) app gives generated token to Cognito, gets an id and credentials.

    To catch the login event, you would need some kind of back end that intercepts the login event and has some kind of mapping of login to means of authentication, then once that provider approves the login, you can trigger the auth text/push notification...etc.

    Update: this is no longer true, the Cognito User Pools service does manage users for you and allows SMS MFA for authentication.