Module: VaultPlugin::API::Backend
Defined Under Namespace
Classes: Client
Instance Method Summary
collapse
Methods included from Helpers
#add_token_metadata?, #settings_ttl, #to_seconds, #token_options, #valid_ttl?, #vault_settings
#auth_backend, #auth_module, #authorized?, #create_setting_accessors, #vault_client
Instance Method Details
#creation_ttl ⇒ Object
60
61
62
|
# File 'lib/smart_proxy_vault/api.rb', line 60
def creation_ttl
vault.lookup_self[:data][:creation_ttl]
end
|
#issue(ttl) ⇒ Object
52
53
54
55
56
57
58
|
# File 'lib/smart_proxy_vault/api.rb', line 52
def issue(ttl)
begin
vault.issue_token options(ttl)
rescue StandardError => e
log_halt 500, 'Failed to generate Vault token ' + e.message
end
end
|
37
38
39
40
41
|
# File 'lib/smart_proxy_vault/api.rb', line 37
def metadata
return {} unless add_token_metadata?
{ display_name: vault_client,
meta: { client: vault_client, smartproxy_generated: true } }
end
|
#options(ttl) ⇒ Object
43
44
45
46
|
# File 'lib/smart_proxy_vault/api.rb', line 43
def options(ttl)
options = metadata.merge token_options
options.merge(ttl: ttl) unless ttl.nil?
end
|
#renew ⇒ Object
64
65
66
67
68
69
70
|
# File 'lib/smart_proxy_vault/api.rb', line 64
def renew
begin
vault.renew_self
rescue StandardError => e
puts 'Failed to renew Vault token ' + e.message
end
end
|
#start_renewal ⇒ Object
72
73
74
75
76
77
78
79
|
# File 'lib/smart_proxy_vault/api.rb', line 72
def start_renewal
Thread.new do
while true do
renew
sleep to_seconds(creation_ttl/3)
end
end
end
|
#vault ⇒ Object
48
49
50
|
# File 'lib/smart_proxy_vault/api.rb', line 48
def vault
Client.new
end
|