Sha256: aafd3275b8b5008a146eb58216afe3f9aa066515692bfef9f3b889b150467944

Contents?: true

Size: 833 Bytes

Versions: 4

Compression:

Stored size: 833 Bytes

Contents

# frozen_string_literal: true

module RailsBase::Mfa::Strategy
  class TimeBased < Base
    def self.description
      "MFA is required every #{RailsBase.config.mfa.reauth_duration}"
    end

    def require_mfa?(mfa_last_used:, **)
      if mfa_last_used.nil?
        log(level: :info, msg: "#{user_prepend} : User has not succesfully logged into mfa")
        return true
      end

      log(level: :info, msg: "#{user_prepend} : User last used mfa #{mfa_last_used.utc} (vs #{Time.now.utc})")
      required_line = mfa_last_used.utc + RailsBase.config.mfa.reauth_duration
      log(level: :info, msg: "#{user_prepend} : User required to reauth after #{required_line}")
      status = required_line < Time.now.utc
      log(level: :info, msg: "#{user_prepend} : User required to reauth? #{status}")

      status
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rails_base-0.82.0 app/services/rails_base/mfa/strategy/time_based.rb
rails_base-0.81.1 app/services/rails_base/mfa/strategy/time_based.rb
rails_base-0.81.0 app/services/rails_base/mfa/strategy/time_based.rb
rails_base-0.80.0 app/services/rails_base/mfa/strategy/time_based.rb