Class: Sambot::Domain::Vault

Inherits:
Object
  • Object
show all
Defined in:
lib/sambot/domain/vault.rb

Constant Summary collapse

ENVIRONMENT_VARIABLES =
{
  VAULT_ADDR: 'https://localhost:8200',
  VAULT_SKIP_VERIFY: true
}
ENV_ROOT =
'/etc/profile.d/'

Class Method Summary collapse

Class Method Details

.authenticate(username, password) ⇒ Object



14
15
16
17
# File 'lib/sambot/domain/vault.rb', line 14

def self.authenticate(username, password)
  secret = ::Vault.auth.ldap(username, password)
  secret.auth.client_token
end

.save_token(token) ⇒ Object



26
27
28
# File 'lib/sambot/domain/vault.rb', line 26

def self.save_token(token)
  File.write("~/.vault-token", token)
end

.setup_environment(root = ENV_ROOT) ⇒ Object



19
20
21
22
23
24
# File 'lib/sambot/domain/vault.rb', line 19

def self.setup_environment(root = ENV_ROOT)
  ENVIRONMENT_VARIABLES.each_pair do |key, value|
    path = File.join(root, "#{key}.sh")
    File.write(path, "export #{key}=#{value}")
  end
end