gpt4 book ai didi

amazon-web-services - 使用 Amazon S3 SignedURL 从浏览器客户端 PUT 文件是否安全?

转载 作者:行者123 更新时间:2023-12-02 18:39:24 25 4
gpt4 key购买 nike

我的后端是一个 Nodejs 应用程序,我希望用户将图像上传到 Amazon S3 存储桶。

从我的服务器运行:

const s3 = new AWS.S3({
params: {
Bucket: bucket
}
});

app.get('/api/images/signed-url', authMiddleware, (req, res) => {
s3.getSignedUrl('putObject',
{ ContentType: 'image/jpeg', Key: uuid() + '.jpeg' },
(_err, url) => res.send({ signedUrl })
})

然后从我的浏览器客户端上传到该端点

URL 如下所示:

https://my-s3-bucket.s3.ap-southeast-2.amazonaws.com/0050db00-c64c-419a-83c2-e8615120f458.jpeg?AWSAccessKeyId=MY_ACCESS_KEY&Content-Type=image%2Fjpeg&Expires=1625365030&Signature=1ebnshTgeMKoLMAH%2Bi2FLletsAU%3D

鉴于此网址包含我的 MY_ACCESS_KEY_ID,与客户共享是否安全?我不分享我的 secret (显然),但它只是等式的一半。

最佳答案

AWS 编程 key 具有访问 key ID 和 secret key

将 ID 视为计算机的用户名,将 key 视为密码。请注意,URL 中的它是访问 key ID,而不是 secret key 。因此人们可以看到您的用户名。

access-key-id must be specified so the service knows who's making the request.

即使您担心暴露访问 key ID,您也应该从概念上记住“s3preSignedURL 是基于时间的”,它仅在某个特定时间内有效

如果您担心该网址是否在可接受的有效时间范围内与其他人共享,请微调您的权限,因为

A presigned URL gives you access to the object identified in the URL, provided that the creator of the presigned URL has permissions to access that object. That is, if you receive a presigned URL to upload an object, you can upload the object only if the creator of the presigned URL has the necessary permissions to upload that object.

这些是一些详细讨论此问题的帖子 post 1post 2

关于amazon-web-services - 使用 Amazon S3 SignedURL 从浏览器客户端 PUT 文件是否安全?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68242191/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com