Class: Rails::Vault::JWT::TokenProvider::RoleID

Inherits:
BaseProvider
  • Object
show all
Defined in:
lib/rails/vault/jwt/token_provider/role_id.rb

Instance Attribute Summary

Attributes inherited from BaseProvider

#expire_time

Instance Method Summary collapse

Methods inherited from BaseProvider

#bearer_token, #client, #token, #token_expired?, #token_life_remaining, #token_valid?

Constructor Details

#initialize(*args, mount_name: 'approle', role_id: nil, secret_id: nil, token_ttl: '5m') ⇒ RoleID

Returns a new instance of RoleID.



8
9
10
11
12
13
14
# File 'lib/rails/vault/jwt/token_provider/role_id.rb', line 8

def initialize(*args, mount_name: 'approle', role_id: nil, secret_id: nil, token_ttl: '5m')
  super
  @mount_name = mount_name
  @role_id = role_id || ENV.fetch('VAULT_ROLE_ID')
  @secret_id = secret_id || ENV.fetch('VAULT_SECRET_ID')
  @token_ttl = token_ttl
end

Instance Method Details

#authObject



16
17
18
19
# File 'lib/rails/vault/jwt/token_provider/role_id.rb', line 16

def auth
  client.logical.write("auth/#{@mount_name}/login", role_id: @role_id, secret_id: @secret_id,
                                                    ttl: @token_ttl)&.auth
end