module MSS::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
@return [String] Returns the MSS
access key id. @raise (see credentials
)
# File lib/mss/core/credential_providers.rb, line 60 def access_key_id credentials[:access_key_id] end
@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/mss/core/credential_providers.rb, line 39 def credentials raise Errors::MissingCredentialsError unless set? @cached_credentials.dup end
Clears out cached/memoized credentials. Causes the provider to refetch credentials from the source. @return [nil]
# File lib/mss/core/credential_providers.rb, line 80 def refresh @cached_credentials = nil end
@return [String] Returns the MSS
secret access key. @raise (see credentials
)
# File lib/mss/core/credential_providers.rb, line 66 def secret_access_key credentials[:secret_access_key] end
@return [String,nil] Returns the MSS
session token or nil if these
are not session credentials.
@raise (see credentials
)
# File lib/mss/core/credential_providers.rb, line 73 def session_token credentials[:session_token] end
@return [Boolean] Returns true if has credentials and it contains
at least the `:access_key_id` and `:secret_access_key`.
# File lib/mss/core/credential_providers.rb, line 47 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
Protected Instance Methods
This method is called on a credential provider to fetch credentials. The credentials hash returned from this method will be cached until the client calls {#refresh}. @return [Hash]
# File lib/mss/core/credential_providers.rb, line 90 def get_credentials # should be defined in provider classes. raise NotImplementedError end