Sha256: a15e5ea8d2100d22f58c404aaf64c84ff79a6b79585e9cf17d46c3f621f60968

Contents?: true

Size: 725 Bytes

Versions: 11

Compression:

Stored size: 725 Bytes

Contents

require 'addressable/uri'

module CASino
  module ProcessorConcern
    module TwoFactorAuthenticators
      class ValidationResult < CASino::ValidationResult; end

      def validate_one_time_password(otp, authenticator)
        if authenticator.nil? || authenticator.expired?
          ValidationResult.new 'INVALID_AUTHENTICATOR', 'Authenticator does not exist or expired', :warn
        else
          totp = ROTP::TOTP.new(authenticator.secret)
          if totp.verify_with_drift(otp, CASino.config.two_factor_authenticator[:drift])
            ValidationResult.new
          else
            ValidationResult.new 'INVALID_OTP', 'One-time password not valid', :warn
          end
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
casino-2.0.7 app/processors/casino/processor_concern/two_factor_authenticators.rb
casino-3.0.0 app/processors/casino/processor_concern/two_factor_authenticators.rb
casino-3.0.0.pre.2 app/processors/casino/processor_concern/two_factor_authenticators.rb
casino-3.0.0.pre.1 app/processors/casino/processor_concern/two_factor_authenticators.rb
casino-2.0.6 app/processors/casino/processor_concern/two_factor_authenticators.rb
casino-2.0.5 app/processors/casino/processor_concern/two_factor_authenticators.rb
casino-2.0.4 app/processors/casino/processor_concern/two_factor_authenticators.rb
casino-2.0.3 app/processors/casino/processor_concern/two_factor_authenticators.rb
casino-2.0.2 app/processors/casino/processor_concern/two_factor_authenticators.rb
casino-2.0.1 app/processors/casino/processor_concern/two_factor_authenticators.rb
casino-2.0.0 app/processors/casino/processor_concern/two_factor_authenticators.rb