You are viewing documentation for version 1 of the AWS SDK for Ruby. Version 2 documentation can be found here.
Module: AWS::Core::CredentialProviders::Provider
- Included in:
- AssumeRoleProvider, CredentialFileProvider, DefaultProvider, EC2Provider, ENVProvider, SessionProvider, SharedCredentialFileProvider
- Defined in:
- lib/aws/core/credential_providers.rb
Overview
This module is mixed into the various credential provider classes. It provides a unified interface for getting credentials and refreshing them.
Constant Summary
- KEYS =
The list of possible keys in the hash returned by #credentials.
Set[:access_key_id, :secret_access_key, :session_token]
Instance Method Summary collapse
-
#access_key_id ⇒ String
Returns the AWS access key id.
-
#credentials ⇒ Hash
Returns a hash of credentials containg at least the
:access_key_id
and:secret_access_key
. -
#refresh ⇒ nil
Clears out cached/memoized credentials.
-
#secret_access_key ⇒ String
Returns the AWS secret access key.
-
#session_token ⇒ String?
Returns the AWS session token or nil if these are not session credentials.
-
#set? ⇒ Boolean
Returns true if has credentials and it contains at least the
:access_key_id
and:secret_access_key
.
Instance Method Details
#access_key_id ⇒ String
Returns the AWS access key id.
61 62 63 |
# File 'lib/aws/core/credential_providers.rb', line 61 def access_key_id credentials[:access_key_id] end |
#credentials ⇒ 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
.
40 41 42 43 |
# File 'lib/aws/core/credential_providers.rb', line 40 def credentials raise Errors::MissingCredentialsError unless set? @cached_credentials.dup end |
#refresh ⇒ nil
Clears out cached/memoized credentials. Causes the provider to refetch credentials from the source.
81 82 83 |
# File 'lib/aws/core/credential_providers.rb', line 81 def refresh @cached_credentials = nil end |
#secret_access_key ⇒ String
Returns the AWS secret access key.
67 68 69 |
# File 'lib/aws/core/credential_providers.rb', line 67 def secret_access_key credentials[:secret_access_key] end |
#session_token ⇒ String?
Returns the AWS session token or nil if these are not session credentials.
74 75 76 |
# File 'lib/aws/core/credential_providers.rb', line 74 def session_token credentials[:session_token] end |
#set? ⇒ Boolean
Returns true if has credentials and it contains
at least the :access_key_id
and :secret_access_key
.
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/aws/core/credential_providers.rb', line 48 def set? @cache_mutex ||= Mutex.new unless @cached_credentials @cache_mutex.synchronize do @cached_credentials ||= get_credentials end end !!(@cached_credentials[:access_key_id] && @cached_credentials[:secret_access_key]) end |