Module: Istox::Vault

Defined in:
lib/istox/helpers/vault.rb

Defined Under Namespace

Modules: TOTP

Class Method Summary collapse

Class Method Details

.get_otp(sid, host) ⇒ Object



76
77
78
79
# File 'lib/istox/helpers/vault.rb', line 76

def get_otp(sid, host)
  ::Istox::Vault::TOTP.create(sid, host)
  Istox::Vault::TOTP.generate_code(sid)
end

.initialize(secret_key, file_location) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/istox/helpers/vault.rb', line 61

def initialize(secret_key, file_location)
  ::Vault.configure do |config|
    config.address = secret_key

    if File.exist?(file_location)
      token = File.read(file_location).strip
      config.token = token
      config.ssl_verify = false
      config.timeout = 60
    else
      log.info 'Vault token not found, OTP will not be able to use'
    end
  end
end

.logicalObject



57
58
59
# File 'lib/istox/helpers/vault.rb', line 57

def logical
  ::Vault.logical
end

.validate_otp(sid, otp) ⇒ Object



81
82
83
# File 'lib/istox/helpers/vault.rb', line 81

def validate_otp(sid, otp)
  ::Istox::Vault::TOTP.validate?(sid, otp)
end