Implement Uploading Images to S3 with Signature Version 4 (AWS4)

490 views
Skip to first unread message

Alexei Antipov

unread,
Jan 26, 2015, 11:21:14 AM1/26/15
to loopb...@googlegroups.com
Hey there!

I have setup a bucket at Amazon S3 with region "Frankfurt".
Api requests for this bucket require to use AWS Signature Version 4 for authentication. 
In 'raw' code I can satisfy this requirement by including parameter `signatureVersion: 'v4'` in the code `var s3 = new AWS.S3({signatureVersion: 'v4', region: 'eu-central-1'});`.
But I can't understand how I can implement it via `loopback-component-storage`.

I have setup a connection to S3 as pointed at http://docs.strongloop.com/display/public/LB/Storage+service
`Get` request `/containers` works fine and returns my S3 buckets.
But `Get` request `/containers/{container}` doesn't works and I guess it is because of the requirement to use `signatureVersion: 'v4'`:
{
  "error": {
    "name": "InvalidRequest",
    "status": 400,
    "message": "The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256.",
    "code": "InvalidRequest",
    "time": "2015-01-26T16:11:47.586Z",
    "statusCode": 400,
    "retryable": false,
    "retryDelay": 30,
    "stack": "InvalidRequest: The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256.\n    at Request.extractError (/Users/alexei/Dropbox/Projects/Placetoview/source/api/node_modules/loopback-component-storage/node_modules/pkgcloud/node_modules/aws-sdk/lib/services/s3.js:343:35)\n    at Request.callListeners (...)"
  }
}

I tried to specify `signatureVersion` as option in the `loopback.createDataSource`: 

var ds = loopback.createDataSource({
  connector
: require('loopback-component-storage'),
  provider
: 'amazon',
  key
: 'CJw1f77+/z0aNy8cc1R/5DZslKMNv5dAq9khpEEK',
  keyId
: 'AKIAJDRMDXKZTQAOJ34A',
  signatureVersion
: 'v4'
});



But this doesn't work.

What is the right way to point `signatureVersion` param?

Samuel Picek

unread,
Mar 14, 2015, 6:50:33 PM3/14/15
to loopb...@googlegroups.com, antipov...@gmail.com
+1

I have the same problem.  Did you manage to fix it?

Edgar Kuskov

unread,
Jul 2, 2015, 7:33:49 AM7/2/15
to loopb...@googlegroups.com, antipov...@gmail.com
+1 did you solve this?

Pirmin Riedmann

unread,
Jul 21, 2015, 11:30:44 AM7/21/15
to loopb...@googlegroups.com
+1

Raymond Feng

unread,
Jul 21, 2015, 12:07:38 PM7/21/15
to loopb...@googlegroups.com
We need to open an issue against https://github.com/pkgcloud/pkgcloud to add support for AWS4. I found a module to sign the http request to S3: https://github.com/mhart/aws4. But it needs to be incorporated into pkgcloud.

Thanks,

---
Raymond Feng
Co-Founder and Architect @ StrongLoop, Inc.

StrongLoop makes it easy to develop APIs in Node, plus get DevOps capabilities like monitoring, debugging and clustering.

On Jul 21, 2015, at 8:30 AM, Pirmin Riedmann <pirm...@gmail.com> wrote:

+1

--
You received this message because you are subscribed to the Google Groups "LoopbackJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to loopbackjs+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/loopbackjs/5332339a-3157-4dd2-bd3a-5a9dbc5a8e3f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tal Pascovich

unread,
Jul 24, 2016, 6:13:00 AM7/24/16
to LoopbackJS, ray...@strongloop.com
Is this still an issue?  I'm still getting a : SignatureDoesNotMatch error....
Reply all
Reply to author
Forward
0 new messages