Closed hkairi closed 3 years ago
Which version of rotp
are you using? The latest update works for me if I use rotp 4.0.2
, but not rotp 3.3.1
.
i am using the "rotp 4.0.2".
https://www.driftingruby.com/episodes/two-factor-authentication
This was working before the update. Today it does not work
Ah, I thought perhaps you referred to the current version from GitHub.
The DriftingRuby episode uses the released version 1.2.0. The released version is compatible with rotp
3.3.1, and not 4.0.2.
Try adding to the Gemfile
gem 'rotp', '= 3.3.1'
Then run bundle update
. This makes it work for me.
Hello,
I am using both versions ...
today i fixed the version of rotp to '3.3.1' and i have this error :
undefined method `to_i' for {:drift_behind=>60}:Hash Did you mean? to_s to_a to_h
I've had to go back to 3.3.1 as well to make this work again.
What period of time do you use to make work ?
Hi everyone! 👋
Is this still a issue?
Hey guys, how is it going? I figured what happened with my customers. I was commenting on this issue before but seems it's more related to this. I realized that my customers couldn't enable their accounts because there is some delay between their Google Authenticator app and the application. I was digging until I found some workaround for me: I added also drift_ahead on my verification by overriding the authenticate_otp
to add the drift_ahead
arg to ROTP::TOTP#verify
:
ActiveModel::OneTimePassword::InstanceMethodsOnActivation.module_eval do
def authenticate_otp(code, options = {})
return true if backup_codes_enabled? && authenticate_backup_code(code)
if otp_counter_based
hotp = ROTP::HOTP.new(otp_column, digits: otp_digits)
result = hotp.verify(code, otp_counter)
if result && options[:auto_increment]
self.otp_counter += 1
save if respond_to?(:changed?) && !new_record?
end
result
else
totp = ROTP::TOTP.new(otp_column, digits: otp_digits)
if drift = options[:drift]
totp.verify(code, drift_behind: drift, drift_ahead: drift)
else
totp.verify(code)
end
end
end
end
Maybe this solution is acceptable and could be considered to go to the main branch. What do you guys think?
@diegopolido This delay, that you mentioned, is related to clock time in device (timezone or something else)?
@pedrofurtado could be
Feel free to open a PR with this suggestion, ok? 🤝 🍻 The issue was resolved by workaround, so we are closing this, for now
Hello
After the last update ... OTP codes generated by the Google Authenticator app don't work.
The OTP codes generated by "user.otp_code" work well
( Everything was working fine before the gem update)