You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add a standardized two-factor authentication interface for connecting devise extensions that implement 2FA methods #5842
Every gem that adds 2FA support to Devise (devise-webauthn, devise-otp, devise-two-factor, etc.) independently solves the same set of problems:
Redirecting to a 2FA challenge page after password validation succeeds
Preserving remember_me across the two-step flow
Preventing 2FA bypass through password reset (PasswordsController#update calls sign_in directly)
Because each gem solves these independently – and with fundamentally different architectural choices (e.g. devise-two-factor replaces DatabaseAuthenticatable with a strategy that validates password and the OTP code, while devise-webauthn runs a separate Warden strategy) – there is no shared contract between them. An application that wants to offer users a choice between two second factors (e.g. WebAuthn and TOTP) cannot simply install two 2FA gems and have them cooperate out of the box.
I believe the Devise ecosystem would benefit from a standardized interface that extension gems can hook into instead of reimplementing the same patterns independently.
Just wanted to leave you a quick note that I've seen the change, just haven't had time to fully dig into it... it's quite a lot :)
To be honest, I've always thought Devise should provide some minimal 2FA (with OTP probably) implementation, and at a glance I feel a bit uneasy supporting a whole lot of infrastructure without a concrete implementation... anyway, I'll be taking a better look and reporting back. Thanks again!
No worries at all – I know the PR is pretty big, please take your time. I really appreciate the effort that goes into maintaining OSS gems. And as mentioned in the PR, I'm happy to split this into smaller PRs if that would make review easier.
I actually share your concern about adding infrastructure without a concrete implementation. That's exactly why I tried to ground the proposal by applying the infrastructure changes to a few existing Devise extensions and bringing them together into a demo app – see the "Validating the interface" section of the PR description for details. In fact, I also considered adding recovery codes as a 2FA strategy within the same PR, but decided to leave that for a follow-up to keep the scope manageable. If it helps move things forward, I'd also be glad to contribute to a built-in OTP implementation on top of this interface.
Activity
carlosantoniodasilva commentedon May 15, 2026
@santiagorodriguez96 thanks for writing this up and opening the PR.
Just wanted to leave you a quick note that I've seen the change, just haven't had time to fully dig into it... it's quite a lot :)
To be honest, I've always thought Devise should provide some minimal 2FA (with OTP probably) implementation, and at a glance I feel a bit uneasy supporting a whole lot of infrastructure without a concrete implementation... anyway, I'll be taking a better look and reporting back. Thanks again!
santiagorodriguez96 commentedon May 25, 2026
Hey @carlosantoniodasilva!
No worries at all – I know the PR is pretty big, please take your time. I really appreciate the effort that goes into maintaining OSS gems. And as mentioned in the PR, I'm happy to split this into smaller PRs if that would make review easier.
I actually share your concern about adding infrastructure without a concrete implementation. That's exactly why I tried to ground the proposal by applying the infrastructure changes to a few existing Devise extensions and bringing them together into a demo app – see the "Validating the interface" section of the PR description for details. In fact, I also considered adding recovery codes as a 2FA strategy within the same PR, but decided to leave that for a follow-up to keep the scope manageable. If it helps move things forward, I'd also be glad to contribute to a built-in OTP implementation on top of this interface.
Thanks again!
santiagorodriguez96 commentedon May 25, 2026
Sorry, misclicked 🥴