class Cerberus::DefaultCredentialsProviderChain
Default credentials provider chain
Constants
- AWS_EC2_METADATA_URL
AWS metadata instance URL
Public Class Methods
new(url_resolver, region = nil, instance_metadata_url = AWS_EC2_METADATA_URL)
click to toggle source
# File lib/cerberus/default_credentials_provider_chain.rb, line 19 def initialize(url_resolver, region = nil, instance_metadata_url = AWS_EC2_METADATA_URL) # return default array of providers @providers = [Cerberus::EnvCredentialsProvider.new, Cerberus::AwsPrincipalCredentialsProvider.new(url_resolver, region, instance_metadata_url)] end
Public Instance Methods
get_credentials_provider()
click to toggle source
Return the first provider in the default hierarchy that has a valid token
# File lib/cerberus/default_credentials_provider_chain.rb, line 29 def get_credentials_provider @providers.each { |p| begin # if token is assigned, that's the provider we want. # providers must throw NoValueError so that we can fall to the next provider if necessary CerberusUtils::get_credentials_from_provider(p) return p rescue Cerberus::Exception::NoValueError next end } # we should have found and returned a valid provider above, else there's a problem CerberusUtils::Log.instance.error("Could not find a valid provider") raise Cerberus::Exception::NoValidProviders.new end