class Aws::TokenProviderChain

@api private

Public Class Methods

new(config = nil) click to toggle source
# File lib/aws-sdk-core/token_provider_chain.rb, line 6
def initialize(config = nil)
  @config = config
end

Public Instance Methods

resolve() click to toggle source

@return [TokenProvider, nil]

# File lib/aws-sdk-core/token_provider_chain.rb, line 11
def resolve
  providers.each do |method_name, options|
    provider = send(method_name, options.merge(config: @config))
    return provider if provider && provider.set?
  end
  nil
end

Private Instance Methods

determine_profile_name(options) click to toggle source
# File lib/aws-sdk-core/token_provider_chain.rb, line 46
def determine_profile_name(options)
  (options[:config] && options[:config].profile) || ENV['AWS_PROFILE'] || ENV['AWS_DEFAULT_PROFILE'] || 'default'
end
providers() click to toggle source
# File lib/aws-sdk-core/token_provider_chain.rb, line 21
def providers
  [
    [:static_profile_sso_token, {}],
    [:sso_token, {}]
  ]
end
sso_token(options) click to toggle source
# File lib/aws-sdk-core/token_provider_chain.rb, line 37
def sso_token(options)
  profile_name = determine_profile_name(options)
  if Aws.shared_config.config_enabled?
    Aws.shared_config.sso_token_from_config(profile: profile_name)
  end
rescue Errors::NoSuchProfileError
  nil
end
static_profile_sso_token(options) click to toggle source
# File lib/aws-sdk-core/token_provider_chain.rb, line 28
def static_profile_sso_token(options)
  if Aws.shared_config.config_enabled? && options[:config] && options[:config].profile
    Aws.shared_config.sso_token_from_config(
      profile: options[:config].profile
    )
  end
end