Class: Conjur::API::APIKeyAuthenticator

Inherits:
Object
  • Object
show all
Includes:
TokenExpiration
Defined in:
lib/conjur/base.rb

Overview

When the API is constructed with an API key, the token can be refreshed using the username and API key. This authenticator assumes that the token was minted immediately before the API instance was created.

Constant Summary

Constants included from TokenExpiration

TokenExpiration::TOKEN_STALE

Instance Attribute Summary collapse

Attributes included from TokenExpiration

#token_born

Instance Method Summary collapse

Methods included from TokenExpiration

#gettime, #needs_token_refresh?, #token_age, #update_token_born

Constructor Details

#initialize(account, username, api_key) ⇒ APIKeyAuthenticator

Returns a new instance of APIKeyAuthenticator.



212
213
214
215
216
217
218
# File 'lib/conjur/base.rb', line 212

def initialize , username, api_key
  @account = 
  @username = username
  @api_key = api_key
  
  update_token_born
end

Instance Attribute Details

#accountObject (readonly)

Returns the value of attribute account.



210
211
212
# File 'lib/conjur/base.rb', line 210

def 
  @account
end

#api_keyObject (readonly)

Returns the value of attribute api_key.



210
211
212
# File 'lib/conjur/base.rb', line 210

def api_key
  @api_key
end

#usernameObject (readonly)

Returns the value of attribute username.



210
211
212
# File 'lib/conjur/base.rb', line 210

def username
  @username
end

Instance Method Details

#refresh_tokenObject



220
221
222
223
224
# File 'lib/conjur/base.rb', line 220

def refresh_token
  Conjur::API.authenticate(username, api_key, account: ).tap do
    update_token_born
  end
end