Class: AWS::Core::CredentialProviders::SessionProvider

Inherits:
Object
  • Object
show all
Includes:
Provider
Defined in:
lib/aws/core/credential_providers.rb

Overview

Session Credential Provider

The session provider consumes long term credentials (:access_key_id and :secret_access_key) and requests a session from STS. It then returns the short term credential set from STS.

Calling #refresh causes the session provider to request a new set of credentials.

This session provider is currently only used for DynamoDB which requires session credentials.

Constant Summary

Constants included from Provider

Provider::KEYS

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Provider

#access_key_id, #credentials, #secret_access_key, #session_token

Constructor Details

#initialize(long_term_credentials) ⇒ SessionProvider

Returns a new instance of SessionProvider.

Parameters:

  • long_term_credentials (Hash)

    A hash of credentials with :access_key_id and :secret_access_key (but not :session_token).



347
348
349
350
351
352
353
# File 'lib/aws/core/credential_providers.rb', line 347

def initialize long_term_credentials
  @static = StaticProvider.new(long_term_credentials)
  if @static.session_token
    raise ArgumentError, 'invalid option :session_token'
  end
  @session_mutex = Mutex.new
end

Class Method Details

.for(long_term_credentials) ⇒ Object

Parameters:

  • long_term_credentials (Hash)

    A hash of credentials with :access_key_id and :secret_access_key (but not :session_token).



330
331
332
333
334
335
336
# File 'lib/aws/core/credential_providers.rb', line 330

def for long_term_credentials
  @create_mutex.synchronize do
    @session_providers ||= {}
    @session_providers[long_term_credentials[:access_key_id]] =
      self.new(long_term_credentials)
  end
end

Instance Method Details

#refreshnil

Clears out cached/memoized credentials. Causes the provider to refetch credentials from the source.

Returns:

  • (nil)


361
362
363
364
# File 'lib/aws/core/credential_providers.rb', line 361

def refresh
  refresh_session
  orig_refresh
end