two_factor_authentication icon indicating copy to clipboard operation
two_factor_authentication copied to clipboard

Feature enable otp

Open benjaminwols opened this issue 10 years ago • 4 comments

This PR adds an enable option, which lets the user enable and disable tfa.

If the need_two_factor_authentication? method returns true and otp is not enabled, the user is redirected to the :new view, where an QR code is shown if using an app and there is a link to ask for a direct otp code.

If the user confirms his code, otp is enabled and the user is asked next time for a otp code.

You can add a link to 'edit_user_two_factor_authentication_path' to let the user disable tfa.

I would love to get your feedback.

benjaminwols avatar Nov 30 '16 12:11 benjaminwols

Is it wise to be submitting the totp_secret in the form? I faced a similar situation recently and opted to:

  • generate the code and update the user first
  • display the QR code
  • when they confirm by entering the authenticator code, mark them as otp_enabled.

If they don't confirm there and then, I regenerate the code next time and ask them to confirm using the new code.

chrise86 avatar Jul 31 '17 09:07 chrise86

Good point. I will take a look at this later this week.

benjaminwols avatar Aug 01 '17 15:08 benjaminwols

The problem with generating the code and update the user first, is that when the user does not confirm by entering the authenticator code we will update the user again and again.

Sending the topt_secret in the form is fine because we are showing it on the qrcode (is the same thing).

PD: Maybe if somebody sees or changes the topt_secret via javascript would be a risk. I do not know.

PD2: I did a similar way of this PR by hand on my project (I think everybody will need to write this).

Xosmond avatar Oct 02 '17 02:10 Xosmond

@Houdini Do you have any thoughts on this matter? I think it provides a solution to Issue #32.

benjaminwols avatar Dec 04 '17 19:12 benjaminwols