Class: VaultConnection

Inherits:
ApplicationRecord
  • Object
show all
Includes:
Authorizable
Defined in:
app/models/vault_connection.rb

Instance Method Summary collapse

Instance Method Details

#perform_renew_tokenObject



56
57
58
# File 'app/models/vault_connection.rb', line 56

def perform_renew_token
  RefreshVaultToken.perform_later(id)
end

#renew_token!Object



47
48
49
50
51
52
53
54
# File 'app/models/vault_connection.rb', line 47

def renew_token!
  client.renew_token
  save!
rescue StandardError => e
  # rubocop:disable Rails/SkipsModelValidations
  update_column(:vault_error, e.message)
  # rubocop:enable Rails/SkipsModelValidations
end

#token_valid?Boolean

Returns:

  • (Boolean)


39
40
41
42
43
44
45
# File 'app/models/vault_connection.rb', line 39

def token_valid?
  return false unless with_token?
  return false unless vault_error.nil?
  return true unless expire_time

  expire_time > Time.zone.now
end

#with_approle?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'app/models/vault_connection.rb', line 35

def with_approle?
  role_id.present? && secret_id.present?
end

#with_token?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'app/models/vault_connection.rb', line 31

def with_token?
  token.present?
end