简体   繁体   English

如何使用 cognito 访问私有 s3 存储桶

[英]How to get access to private s3 bucket using cognito

I have a cognito user pool which is connected to google as identity providers (so that I can log in with a gmail account).我有一个认知用户池,它作为身份提供者连接到谷歌(这样我就可以使用 gmail 帐户登录)。 I also have a private bucket s3 with files ().我还有一个带有文件()的私有存储桶 s3。 How can I use my lambda function, using the token returned by Cognito (AcessToken, IdToken) to get access to my s3 bucket which is not public?如何使用我的 lambda function,使用 Cognito 返回的令牌(AcessToken,IdToken)来访问我的不公开的 s3 存储桶?

I just want to use my cognito to access my private files on s3.我只想使用我的 cognito 访问我在 s3 上的私人文件。

Something like the Cognito Authorizer for lambda functions just for s3 bucket.类似于 lambda 的 Cognito Authorizer 功能仅适用于 s3 存储桶。

You can use Signed URLs to achieve this.您可以使用签名 URL来实现此目的。

Basically, after your user successfully authenticated by Cognito, your Lambda function will generate s3 pre-signed url for object requested and reply it back. Basically, after your user successfully authenticated by Cognito, your Lambda function will generate s3 pre-signed url for object requested and reply it back.

Example from AWS Documentation AWS 文档中的示例

Also take a look at this AWS forum thread另请查看此AWS 论坛主题

The only way that i know to do this is give the role access to the cognito user我知道这样做的唯一方法是让角色访问 cognito 用户

https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_examples_s3_cognito-bucket.html https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_examples_s3_cognito-bucket.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM