Module: SimpleAWS::Signing::Version3
- Included in:
- SimpleAWS::SES
- Defined in:
- lib/simple_aws/signing/version3.rb
Overview
Implementation of "Signature Version 3" signing, the X-Amzn-Authorization header
Instance Method Summary collapse
- #build_signature_for(timestamp) ⇒ Object
-
#finish_and_sign_request(request) ⇒ Object
Build and sign the final request, as per the rules here: http://docs.amazonwebservices.com/ses/latest/DeveloperGuide/QueryInterface.Authentication.html.
Instance Method Details
#build_signature_for(timestamp) ⇒ Object
32 33 34 |
# File 'lib/simple_aws/signing/version3.rb', line 32 def build_signature_for() OpenSSL::HMAC.digest("sha256", self.secret_key, .httpdate) end |
#finish_and_sign_request(request) ⇒ Object
Build and sign the final request, as per the rules here: http://docs.amazonwebservices.com/ses/latest/DeveloperGuide/QueryInterface.Authentication.html
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/simple_aws/signing/version3.rb', line 14 def finish_and_sign_request(request) = Time.now.utc request.params.merge!({ "AWSAccessKeyId" => self.access_key, "Timestamp" => .strftime("%Y-%m-%dT%H:%M:%SZ"), "Version" => self.version }) request.headers["Date"] = .httpdate request.headers["X-Amzn-Authorization"] = "AWS3-HTTPS AWSAccessKeyId=#{self.access_key}, " + "Algorithm=HmacSHA256, " + "Signature=#{Base64.encode64(build_signature_for(timestamp)).chomp}" request end |