AWS API签署POST请求的Jav​​aScriptAPI、AWS、POST、aScript

2023-09-12 00:07:08 作者:戒烟不如戒情丶

我想要做的: 最后:我想填充从一个浏览器扩展(Safari浏览器,Chrome浏览器)的AWS室壁运动流。 我需要使用签名过程(V4)将请求发送到AWS;这包括了设置页眉和加密它们(远程服务器与AWS密钥)来最后加入的请求。

What I'm trying to do: Ultimately: I want to populate an AWS Kinesis stream from a browser extension (Safari, Chrome). I need to send the request to AWS using a signing process (v4); this involves setting headers and encrypting them (on a distant server with the aws secret key) to finally join those to the request.

亚马逊请求头主机被明确定义? 然而使用Javascript严格禁止设置它(和一堆别人的,有充分的理由)

Amazon requests the header "Host" to be explicitly defined… However Javascript strictly disallow setting it (and a bunch of others, for good reasons)

我一定是失去了一些东西,我该怎么办呢?

I must be missing something—how can I do this?

来源: http://docs.aws.amazon.com /general/latest/gr/sigv4-signed-request-examples.html - 的例子是在Python但它表明了服务器端,他们打算使用主机头

sources: http://docs.aws.amazon.com/general/latest/gr/sigv4-signed-request-examples.html - the example is in Python but it shows how server-side they intend to use the Host header

注:我目前使用POST;这个例子的评论描述GET和查询字符串提到的主机,以及:它必须存在一个头在请求

notes: I'm currently using POST; the example's comments describing the GET and query string mention the "Host" as well: it must exist as a header in the request

也:使用类似的设置,我设法把从客户端直接上传到S3斗的autorisation过程的文件略有不同(的'主机'不要求)

also: Using a similar setup, I managed to have a file uploaded from the client directly to an S3 bucket–the autorisation process is slightly different (no requirement for 'Host').

推荐答案

主持人:头被JS XHR自己,当被填写并解析从给定的URL你执行它,同样与卷曲,例如:

The Host: header is being filled in and parsed from the given URL by the JS XHR itself when you execute it, same as with curl, e.g.

curl -v -X POST http://example.org/foo

...会自动添加标题主持人:example.org ...

有关AWS你还需要将它虽然添加到 canonical_headers 清单签名(在全部小写),在您的链接的例子说明。这部分有无关,与实际建立连接,但。

For AWS you'll still need to add it to the canonical_headers list for signing though (and in all lowercase), as described in your linked example. That part has nothing to do with actually establishing a connection though.

 
精彩推荐