Module: Aws::RefreshingCredentials
- Included in:
- AssumeRoleCredentials, AssumeRoleWebIdentityCredentials, CognitoIdentity::CognitoIdentityCredentials, ECSCredentials, InstanceProfileCredentials, ProcessCredentials, SSOCredentials
- Defined in:
- gems/aws-sdk-core/lib/aws-sdk-core/refreshing_credentials.rb
Overview
Base class used credential classes that can be refreshed. This provides basic refresh logic in a thread-safe manner. Classes mixing in this module are expected to implement a #refresh method that populates the following instance variables:
@access_key_id
@secret_access_key
@session_token
@expiration
Constant Summary collapse
- SYNC_EXPIRATION_LENGTH =
5 minutes
300
- ASYNC_EXPIRATION_LENGTH =
10 minutes
600
- CLIENT_EXCLUDE_OPTIONS =
Set.new([:before_refresh]).freeze
Instance Method Summary collapse
-
#credentials ⇒ Credentials
-
#initialize(options = {}) ⇒ Object
-
#refresh! ⇒ void
Refresh credentials.
Instance Method Details
#credentials ⇒ Credentials
29 30 31 32 |
# File 'gems/aws-sdk-core/lib/aws-sdk-core/refreshing_credentials.rb', line 29 def credentials refresh_if_near_expiration! @credentials end |
#initialize(options = {}) ⇒ Object
20 21 22 23 24 25 26 |
# File 'gems/aws-sdk-core/lib/aws-sdk-core/refreshing_credentials.rb', line 20 def initialize( = {}) @mutex = Mutex.new @before_refresh = .delete(:before_refresh) if .is_a?(Hash) @before_refresh.call(self) if @before_refresh refresh end |
#refresh! ⇒ void
This method returns an undefined value.
Refresh credentials.
36 37 38 39 40 41 42 |
# File 'gems/aws-sdk-core/lib/aws-sdk-core/refreshing_credentials.rb', line 36 def refresh! @mutex.synchronize do @before_refresh.call(self) if @before_refresh refresh end end |