aws4-axios icon indicating copy to clipboard operation
aws4-axios copied to clipboard

Allow exclusion of headers from signature

Open chris-gilbert-2 opened this issue 9 months ago • 1 comments

Hi all, I am trying to do something that doesn't appear possible currently, but I think could be possible with a small update. Let me explain the problem I am trying to address, and how I think it could be achieved.

In development and test environments, for non AWS http services we proxy requests via Wiremock - this means that normally requests go to the external service but we can override that behaviour on a per request basis by adding a matching rule so a stubbed response is returned.

This makes per-request behaviour nice and easy to manage - we don't have to re-route requests within our code - just override the default routing by adding a specific matching rule to Wiremock as part of test code.

For calls to a private API gateway we are using aws4-axios, and the problem here is that if we try to proxy via Wiremock, the host header in the signature doesn't match - the signature is created based on a wiremock host, but when a proxied request reaches AWS, the host header has been updated by Wiremock to the private API gateway address.

In our development and test environments we would be comfortable excluding the host header completely from the signature for private api calls, and looking at aws4 source code it seems like that is possible by just adding extraHeadersToIgnore to the request. Looking at aws4-axios, I think that could be as simple as specifying it in here so if it was added to the SigningOptions type and passed through when present that would probably work.

If that sounds reasonable, is it a change you would consider accepting as a PR? I'm happy to contribute if you think this is an okay idea.

Thanks

chris-gilbert-2 avatar May 17 '24 15:05 chris-gilbert-2