Module: MAuth::Signed

Included in:
Faraday::Response, Rack::Request
Defined in:
lib/mauth/request_and_response.rb

Overview

methods for an incoming object which is expected to have a signature.

includer must provide

  • #mcc_authentication which returns that header’s value

  • #mcc_time

OR

  • #x_mws_authentication which returns that header’s value

  • #x_mws_time

Instance Method Summary collapse

Instance Method Details

#fall_back_to_mws_signature_infoObject



127
128
129
# File 'lib/mauth/request_and_response.rb', line 127

def fall_back_to_mws_signature_info
  @signature_info = build_signature_info(x_mws_data)
end

#protocol_versionObject



143
144
145
146
147
148
149
# File 'lib/mauth/request_and_response.rb', line 143

def protocol_version
  if !mcc_authentication.to_s.strip.empty?
    2
  elsif !x_mws_authentication.to_s.strip.empty?
    1
  end
end

#signatureObject



139
140
141
# File 'lib/mauth/request_and_response.rb', line 139

def signature
  signature_info[:signature]
end

#signature_app_uuidObject



131
132
133
# File 'lib/mauth/request_and_response.rb', line 131

def signature_app_uuid
  signature_info[:app_uuid]
end

#signature_infoObject

mauth_client will authenticate with the highest protocol version present and if authentication fails, will fallback to lower protocol versions (if provided). returns a hash with keys :token, :app_uuid, and :signature parsed from the MCC-Authentication header if it is present and if not then the X-MWS-Authentication header if it is present. Note MWSV2 protocol no longer allows more than one space between the token and app uuid.



123
124
125
# File 'lib/mauth/request_and_response.rb', line 123

def signature_info
  @signature_info ||= build_signature_info(mcc_data || x_mws_data)
end

#signature_tokenObject



135
136
137
# File 'lib/mauth/request_and_response.rb', line 135

def signature_token
  signature_info[:token]
end