1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
module Fog
module AWS
class Federation < Fog::Service
extend Fog::AWS::CredentialFetcher::ServiceMethods
recognizes :instrumentor, :instrumentor_name
request_path 'fog/aws/requests/federation'
request 'get_signin_token'
class Mock
def self.data
@data ||= {}
end
def self.reset
@data = nil
end
def initialize(options={})
end
def data
self.class.data
end
def reset_data
self.class.reset
end
end
class Real
include Fog::AWS::CredentialFetcher::ConnectionMethods
def initialize(options={})
@instrumentor = options[:instrumentor]
@instrumentor_name = options[:instrumentor_name] || 'fog.aws.federation'
@connection_options = options[:connection_options] || {}
@host = 'signin.aws.amazon.com'
@path = '/federation'
@scheme = 'https'
@connection = Excon.new("#{@scheme}://#{@host}#{@path}")
end
def request(action, session)
response = @connection.get(
:query => "Action=#{action}&SessionType=json&Session=#{session}",
:expects => 200
).body
Fog::JSON.decode(response)
end
end
end
end
end
|