TkTech / ckanext-cloudstorage

Implements support for resource storage against multiple popular providers via apache-libcloud (S3, Azure Storage, etc...)
MIT License
35 stars 55 forks source link

Signature should include Content-Type header #28

Closed jeverling closed 6 years ago

jeverling commented 6 years ago

When trying to preview a JSON file stored on S3 with the help of ckanext-cloudstorage, it fails with the following error message for the Text preview tab:

SignatureDoesNotMatch
The request signature we calculated does not match the signature you provided. Check your key and signing method.

application/json
1533315469

The reason is, that the JavaScript on the Text preview page makes a request with the Content-Type header set to application/json, when the format of the resource is either JSON or GeoJSON. This leads to signature mismatch, because ckanext-cloudstorage doesn't include that header when generating the signature, but the request happens with the Content-Type header.

The GeoJSON or Map viewer preview tabs work fine (if enabled).

ckanext-cloudstorage should take the Content-Type header into account when generating the signature (possibly other headers as well, but I have only encountered a problem with the Text preview and the Content-Type header).