Class: Ey::Hmac::Adapter::Faraday
Constant Summary
AUTHORIZATION_REGEXP
Instance Attribute Summary
#accept_digests, #authorization_header, #options, #request, #service, #sign_with
Instance Method Summary
collapse
#authenticated!, #authenticated?, #authorization, #canonicalize, #initialize, #secure_compare, #signature
Instance Method Details
#authorization_signature ⇒ Object
44
45
46
|
# File 'lib/ey-hmac/adapter/faraday.rb', line 44
def authorization_signature
%w[Authorization AUTHORIZATION].inject(nil){|r, h| r || request[:request_headers][h]}
end
|
#body ⇒ Object
19
20
21
22
23
24
|
# File 'lib/ey-hmac/adapter/faraday.rb', line 19
def body
if request[:body] && request[:body].to_s != ""
request[:body]
else nil
end
end
|
#content_digest ⇒ Object
10
11
12
13
14
15
16
17
|
# File 'lib/ey-hmac/adapter/faraday.rb', line 10
def content_digest
if existing = %w[CONTENT-DIGEST CONTENT_DIGEST Content-Digest Content_Digest].inject(nil) { |r,h| r || request[:request_headers][h] }
existing
elsif digestable = body && Digest::MD5.hexdigest(body)
request[:request_headers]['Content-Digest'] = digestable
else nil
end
end
|
#content_type ⇒ Object
6
7
8
|
# File 'lib/ey-hmac/adapter/faraday.rb', line 6
def content_type
%w[CONTENT-TYPE CONTENT_TYPE Content-Type Content_Type].inject(nil) { |r,h| r || request[:request_headers][h] }
end
|
#date ⇒ Object
26
27
28
29
|
# File 'lib/ey-hmac/adapter/faraday.rb', line 26
def date
existing = %w[DATE Date].inject(nil) { |r,h| r || request[h] }
existing || (request[:request_headers]['Date'] = Time.now.httpdate)
end
|
#method ⇒ Object
2
3
4
|
# File 'lib/ey-hmac/adapter/faraday.rb', line 2
def method
request[:method].to_s.upcase
end
|
#path ⇒ Object
31
32
33
|
# File 'lib/ey-hmac/adapter/faraday.rb', line 31
def path
request[:url].path
end
|
#sign!(key_id, key_secret) ⇒ Object
35
36
37
38
39
40
41
42
|
# File 'lib/ey-hmac/adapter/faraday.rb', line 35
def sign!(key_id, key_secret)
%w[CONTENT-TYPE CONTENT_TYPE Content-Type Content_Type].inject(nil){|r,h| request[:request_headers][h]}
if options[:version]
request[:request_headers]['X-Signature-Version'] = options[:version]
end
request[:request_headers][] = authorization(key_id, key_secret)
end
|