class DefaultProvider
Public Class Methods
finalize_instance(options)
click to toggle source
# File lib/aws_assume_role/credentials/factories/default_chain_provider.rb, line 50 def self.finalize_instance(options) new_opts = options.to_h new_opts[:profile_name] ||= new_opts[:profile] new_opts[:original_profile] = new_opts[:profile_name] instance = allocate instance.send(:initialize, new_opts) instance end
new(options)
click to toggle source
# File lib/aws_assume_role/credentials/factories/default_chain_provider.rb, line 42 def self.new(options) if options.respond_to? :resolve finalize_instance new_with_seahorse(options) else finalize_instance(options) end end
new_with_seahorse(resolver)
click to toggle source
# File lib/aws_assume_role/credentials/factories/default_chain_provider.rb, line 59 def self.new_with_seahorse(resolver) keys = resolver.resolve options = keys.map do |k| [k, resolver.send(k)] end finalize_instance(options.to_h) end
Public Instance Methods
resolve(nil_with_role_not_set: false, explicit_default_profile: false)
click to toggle source
# File lib/aws_assume_role/credentials/factories/default_chain_provider.rb, line 67 def resolve(nil_with_role_not_set: false, explicit_default_profile: false) resolve_final_credentials(explicit_default_profile) # nil_creds = Aws::Credentials.new(nil, nil, nil) return nil if (nil_with_role_not_set && @role_arn && @credentials.credentials.session_token.nil?) || @credentials.nil? @credentials end
to_h()
click to toggle source
# File lib/aws_assume_role/credentials/factories/default_chain_provider.rb, line 76 def to_h to_hash end
Private Instance Methods
resolve_credentials(type, break_if_successful = false, explicit_default_profile = false)
click to toggle source
# File lib/aws_assume_role/credentials/factories/default_chain_provider.rb, line 92 def resolve_credentials(type, break_if_successful = false, explicit_default_profile = false) factories_to_try = Repository.factories[type] factories_to_try.each do |x| options = to_h options[:credentials] = credentials if credentials && credentials.set? logger.debug "About to try credential lookup with #{x}" factory = x.new(options) @region ||= factory.region @profile ||= factory.profile @role_arn ||= factory.role_arn next unless factory.credentials && factory.credentials.set? logger.debug "Profile currently #{@profile}" next if explicit_default_profile && (@profile == "default") && (@profile != @original_profile) @credentials ||= factory.credentials logger.debug "Got #{@credentials}" break if break_if_successful end end
resolve_final_credentials(explicit_default_profile = false)
click to toggle source
# File lib/aws_assume_role/credentials/factories/default_chain_provider.rb, line 82 def resolve_final_credentials(explicit_default_profile = false) resolve_credentials(:credential_provider, true, explicit_default_profile) return @credentials if @credentials && @credentials.set? && !use_mfa && !role_arn resolve_credentials(:second_factor_provider, true, explicit_default_profile) return @credentials if @credentials && @credentials.set? resolve_credentials(:instance_role_provider, true, explicit_default_profile) return @credentials if @credentials && @credentials.set? nil end