Recommendations for Adding 2FA to Phoenix-Based Apps

Hi everyone,

I’m looking to add two-factor authentication (2FA) to a Phoenix-based app and was wondering if anyone has experience or tips to share. Specifically:

  • Are there any libraries or approaches you’d recommend?
  • How do you handle user experience, like backup codes or recovery options?
  • Any pitfalls or best practices I should keep in mind?
  • Any open source-examples?

I’d love to hear about your setups, tools, or even any gotchas you encountered while implementing 2FA.

Thanks in advance!

I’ve read some example using this library (by Dashbit)

Example usage:

2 Likes

There is an open PR on Phoenix Github to add 2FA to phx_gen_auth by @RobinBoers

Add 2FA to the phx.gen.auth generator by RobinBoers · Pull Request #5859 · phoenixframework/phoenix

3 Likes

Wow, great tips! The PR that is adding it to phx_gen_auth looks great. Maybe I could help out in some way while integrating it with our application.