mhart / aws4

Signs and prepares Node.js requests using AWS Signature Version 4
MIT License
699 stars 175 forks source link

Rclone compatibility not working cause of header ignored #141

Closed drappier-charles closed 1 year ago

drappier-charles commented 2 years ago

Usecase : I have an rclone client and I try to do that command : $ rclone copy myinstance:mybucket:test.csv test.csv

It generate a signature from an access_key / access_secret_key couple That signature use a range header cause my file is a file of 500meg

In a middleware I use aws4 library to compute the signature with all the needed data (same couple of key + request information send by rclone)

The signature is not the same, cause aws4 library remove the range header I've found it's hardcoded to ignore it (at signature time)

const HEADERS_TO_IGNORE = {
  authorization: true,
  connection: true,
  'x-amzn-trace-id': true,
  'user-agent': true,
  expect: true,
  'presigned-expires': true,
  range: true
}

I've fork the library to set range to false, it appear to not be overridable with a configuration My question here is, why do you ignore that header? Is there a reason? (other bug?) I understand that's it's a combination of multiple library https://github.com/mhart/aws4fetch/blob/b3aed16b6f17384cf36ea33bcba3c1e9f3bdfefd/src/main.js#L25-L34 Apparently in aws4fetch they ignore it, but as they don't have same usecase I'm not sure it's a good reference.

Thanks by advance, I think best way to go with it, could be to have it in option, keeping your current standard configuration

drappier-charles commented 2 years ago

Look like they got the same issue at the end https://github.com/mhart/aws4fetch/issues/39

mhart commented 1 year ago

You can now do this using extraHeadersToInclude:

aws4.sign({
  service: 'mycustomservice',
  path: '/whatever',
  headers: {
    'Range': 'bytes=200-1000, 2000-6576, 19000-'
  },
  extraHeadersToInclude: {
    'range': true
  }
})