Skip to content
This repository

Make AWS auth signing find headers correctly #344

Merged
merged 1 commit into from over 1 year ago

2 participants

Nathan LaFreniere Mikeal Rogers
Nathan LaFreniere
nlf commented October 15, 2012

The AWS function was using 'content-type' as the header name, which causes access denied errors if the header is actually set as 'Content-Type' since it is an important part of the signing process.

To resolve it, I wrapped the header in a short case-insensitive getter to make sure they are always correctly set for the auth signing.

Mikeal Rogers mikeal merged commit c06c394 into from November 06, 2012
Mikeal Rogers mikeal closed this November 06, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Oct 15, 2012
Nathan LaFreniere switch to a case insensitive getter when fetching headers for aws aut…
…h signing
288c52a
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 11 additions and 2 deletions. Show diff stats Hide diff stats

  1. 13  main.js
13  main.js
@@ -799,6 +799,15 @@ Request.prototype.json = function (val) {
799 799
   }
800 800
   return this
801 801
 }
  802
+function getHeader(name, headers) {
  803
+    var result, re, match
  804
+    Object.keys(headers).forEach(function (key) {
  805
+        re = new RegExp(name, 'i')
  806
+        match = key.match(re)
  807
+        if (match) result = headers[key]
  808
+    })
  809
+    return result
  810
+}
802 811
 Request.prototype.aws = function (opts, now) {
803 812
   if (!now) {
804 813
     this._aws = opts
@@ -811,8 +820,8 @@ Request.prototype.aws = function (opts, now) {
811 820
     , secret: opts.secret
812 821
     , verb: this.method.toUpperCase()
813 822
     , date: date
814  
-    , contentType: this.headers['content-type'] || ''
815  
-    , md5: this.headers['content-md5'] || ''
  823
+    , contentType: getHeader('content-type', this.headers) || ''
  824
+    , md5: getHeader('content-md5', this.headers) || ''
816 825
     , amazonHeaders: aws.canonicalizeHeaders(this.headers)
817 826
     }
818 827
   if (opts.bucket && this.path) {
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.