Module: AWS::Core::Signature::Version3

Included in:
DynamoDB::Request, SimpleWorkflow::Request
Defined in:
lib/aws/core/signature/version_3.rb,
lib/aws/core/signature/version_3_http.rb

Instance Method Summary collapse

Instance Method Details

#add_authorization!(signer) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/aws/core/signature/version_3.rb', line 22

def add_authorization!(signer)

  self.access_key_id = signer.access_key_id

  headers["x-amz-date"] ||= (headers["date"] ||= Time.now.rfc822)
  headers["host"] ||= host

  headers["x-amz-security-token"] = signer.session_token if 
    signer.respond_to?(:session_token) and signer.session_token

  # compute the authorization
  request_hash = OpenSSL::Digest::SHA256.digest(string_to_sign)
  signature = signer.sign(request_hash)
  headers["x-amzn-authorization"] =
    "AWS3 "+
    "AWSAccessKeyId=#{signer.access_key_id},"+
    "Algorithm=HmacSHA256,"+
    "SignedHeaders=#{headers_to_sign.join(';')},"+
    "Signature=#{signature}"
end