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

  • #x_mws_authentication which returns that header’s value

  • #x_mws_time

Instance Method Summary collapse

Instance Method Details

#signatureObject



57
58
59
# File 'lib/mauth/request_and_response.rb', line 57

def signature
  signature_info[:signature]
end

#signature_app_uuidObject



49
50
51
# File 'lib/mauth/request_and_response.rb', line 49

def signature_app_uuid
  signature_info[:app_uuid]
end

#signature_infoObject

returns a hash with keys :token, :app_uuid, and :signature parsed from the X-MWS-Authentication header



42
43
44
45
46
47
# File 'lib/mauth/request_and_response.rb', line 42

def signature_info
  @signature_info ||= begin
    match = x_mws_authentication && x_mws_authentication.match(/\A([^ ]+) *([^:]+):([^:]+)\z/)
    match ? { token: match[1], app_uuid: match[2], signature: match[3] } : {}
  end
end

#signature_tokenObject



53
54
55
# File 'lib/mauth/request_and_response.rb', line 53

def signature_token
  signature_info[:token]
end