Skip to content

Commit

Permalink
Include request body of multipart/form-data requests into AWS4 signature
Browse files Browse the repository at this point in the history
  • Loading branch information
Envek committed Feb 1, 2021
1 parent c15d437 commit b2373d0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/authorizer/aws4.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,16 @@ var _ = require('lodash'),
return callback(hash.digest(digestEncoding));
}

// @todo: formdata body type requires adding new data to form instead of setting headers for AWS auth.
// @todo: formdata body type for S3 requires adding new data to form instead of setting headers for AWS auth.
// Figure out how to do that. See below link:
// AWS auth with formdata: https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-post-example.html
// For now, sign requests as other POST requests for use with API gateway and Lambda functions.
if (body.mode === RequestBody.MODES.formdata) {
formdataBody = bodyBuilder.formdata(body.formdata).body;
hash.update(formdataBody);

return callback(hash.digest(digestEncoding));
}

// ensure that callback is called if body.mode doesn't match with any of the above modes
return callback();
Expand Down

0 comments on commit b2373d0

Please sign in to comment.