Background There are many gems for implementing two-factor authentication for Rails app out there. But, most of them don't work properly with Devise out from the box. Some gems offering seamless integration with Devise gem never work smoothly with our existing Rails app. This is why we share our experience and strategy to implement two-factor authentication using Devise and ActiveModel::Otp gems. This implementation, based on our experience, works very well with the latest Google Authenticator app of both iPhone and Android (version 5.10 as of 2020/06). The rqrcode gem does a nice job to provide us with QR code that's always scannable by the Google Authenticator. Oh, we run this on Ruby 2.6.6 and Rails 6. So, we can guarantee it's working with the latest Rails version at the time we write this (2020/06). 1. Prepare Gemfile You need to add several gems to achieve this. If you have an existing Rails app with Devise already, then feel free to skip the devise gem and add the rest of them. In…
Score: 1.96
Privacy settings changed!
Article is saved. Do you want to continue editing the article or leave and edit later?