Build(deps): Bump rotp from 3.3.1 to 5.1.0 (#8477)

* Build(deps): Bump rotp from 3.3.1 to 5.1.0

Bumps [rotp](https://github.com/mdp/rotp) from 3.3.1 to 5.1.0.
- [Release notes](https://github.com/mdp/rotp/releases)
- [Changelog](https://github.com/mdp/rotp/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mdp/rotp/compare/v3.3.1...v5.1.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* Fix breaking ROTP changes
This commit is contained in:
dependabot-preview[bot]
2019-12-09 14:29:48 +10:00
committed by Martin Brennan
parent 5cef71e885
commit 9b30922109
3 changed files with 18 additions and 5 deletions

View File

@@ -1,13 +1,15 @@
# frozen_string_literal: true
module SecondFactorManager
TOTP_ALLOWED_DRIFT_SECONDS = 30
extend ActiveSupport::Concern
def create_totp(opts = {})
UserSecondFactor.create!({
user_id: self.id,
method: UserSecondFactor.methods[:totp],
data: ROTP::Base32.random_base32
data: ROTP::Base32.random
}.merge(opts))
end
@@ -30,7 +32,13 @@ module SecondFactorManager
last_used = totp.last_used.to_i
end
authenticated = !token.blank? && totp.get_totp_object.verify_with_drift_and_prior(token, 30, last_used)
authenticated = !token.blank? && totp.get_totp_object.verify(
token,
drift_ahead: TOTP_ALLOWED_DRIFT_SECONDS,
drift_behind: TOTP_ALLOWED_DRIFT_SECONDS,
after: last_used
)
if authenticated
totp.update!(last_used: DateTime.now)
break