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

Defined in:
lib/aws/core/signature/version_3.rb

Instance Method Summary collapse

Instance Method Details

#add_authorization!(credentials) ⇒ Object



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 26

def add_authorization! credentials

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

  headers["x-amz-security-token"] = credentials.session_token if 
    credentials.session_token

  # compute the authorization
  headers["x-amzn-authorization"] =
    "AWS3 "+
    "AWSAccessKeyId=#{credentials.access_key_id},"+
    "Algorithm=HmacSHA256,"+
    "SignedHeaders=#{headers_to_sign.join(';')},"+
    "Signature=#{sign(credentials.secret_access_key, string_to_sign)}"
end