Module: RakeVault::Auth::Approle

Defined in:
lib/rake_vault/auth/approle.rb

Class Method Summary collapse

Class Method Details

.configure_stdout(stdout_io) ⇒ Object



29
30
31
32
33
# File 'lib/rake_vault/auth/approle.rb', line 29

def self.configure_stdout(stdout_io)
  RubyVault.configure do |config|
    config.stdout = stdout_io
  end
end

.login(address, path, role_id, secret_id) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/rake_vault/auth/approle.rb', line 8

def self.(address, path, role_id, secret_id)
  role_id = role_id ? "role_id=#{role_id}" : nil
  secret_id = secret_id ? "secret_id=#{secret_id}" : nil

  stdout_io = StringIO.new

  configure_stdout(stdout_io)
  write(address, path, role_id, secret_id)
  reset_stdout
  RakeVault::TokenFile.write(stdout_io.string)
end

.reset_stdoutObject



35
36
37
38
39
# File 'lib/rake_vault/auth/approle.rb', line 35

def self.reset_stdout
  RubyVault.configure do |config|
    config.stdout = $stdout
  end
end

.write(address, path, role_id, secret_id) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/rake_vault/auth/approle.rb', line 20

def self.write(address, path, role_id, secret_id)
  RubyVault.write(
    address:,
    path:,
    data: [role_id, secret_id].compact,
    format: 'json'
  )
end