module AWS::Core::CredentialProviders::Provider

This module is mixed into the various credential provider classes. It provides a unified interface for getting credentials and refreshing them.

Constants

KEYS

The list of possible keys in the hash returned by {credentials}.

Public Instance Methods

access_key_id() click to toggle source

@return [String] Returns the AWS access key id. @raise (see credentials)

# File lib/aws/core/credential_providers.rb, line 51
def access_key_id
  credentials[:access_key_id]
end
credentials() click to toggle source

@return [Hash] Returns a hash of credentials containg at least

the +:access_key_id+ and +:secret_access_key+.  The hash may
also contain a +:session_token+.

@raise [Errors::MissingCredentialsError] Raised when the

+:access_key_id+ or the +:secret_access_key+ can not be found.
# File lib/aws/core/credential_providers.rb, line 38
def credentials
  @cached_credentials ||= begin
    creds = get_credentials
    unless creds[:access_key_id] and creds[:secret_access_key]
      raise Errors::MissingCredentialsError
    end
    creds
  end
  @cached_credentials.dup
end
refresh() click to toggle source

Clears out cached/memoized credentials. Causes the provider to refetch credentials from the source. @return [nil]

# File lib/aws/core/credential_providers.rb, line 71
def refresh
  @cached_credentials = nil
end
secret_access_key() click to toggle source

@return [String] Returns the AWS secret access key. @raise (see credentials)

# File lib/aws/core/credential_providers.rb, line 57
def secret_access_key
  credentials[:secret_access_key]
end
session_token() click to toggle source

@return [String,nil] Returns the AWS session token or nil if these

are not session credentials.

@raise (see credentials)

# File lib/aws/core/credential_providers.rb, line 64
def session_token
  credentials[:session_token]
end

Protected Instance Methods

get_credentials() click to toggle source

This method is called on a credential provider to fetch credentials. The credentials hash returned from this method will be cashed until the client calls {refresh}. @return [Hash]

# File lib/aws/core/credential_providers.rb, line 81
def get_credentials
  # should be defined in provider classes.
  raise NotImplementedError
end