【发布时间】:2014-10-30 00:19:18
【问题描述】:
我正在使用适用于 Android 的 AWS 开发工具包和 Cognito 来验证用户(通过使用 Amazon 登录)到我的 AWS 资源。我正在尝试做的是像这样设置一个 S3 存储桶:
./my-bucket
├── first_user@email.com
└── second_user@email.com
因此,my-bucket 存储桶将包含基于用户电子邮件地址的文件夹。
我第一次设置政策是这样的:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["s3:ListBucket"],
"Resource": ["arn:aws:s3:::my-bucket"]
},
{
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:PutObject",
"s3:DeleteObject"
],
"Resource": [
"arn:aws:s3:::my-bucket/${www.amazon.com:user_id}",
"arn:aws:s3:::my-bucket/${www.amazon.com:user_id}/*"
]
}
]
}
作为测试,我正在尝试为这样的用户下载一个文件夹:
final Map logins = new HashMap();
logins.put("www.amazon.com", token);
credentialsProvider.withLogins(logins);
final TransferManager transferManager = new TransferManager(credentialsProvider);
MultipleFileDownload download = transferManager.downloadDirectory("my-bucket", "first_user@email.com", new File("/sdcard/Download"));
但是,当我运行它时,我得到一个“禁止”异常。如果我修改策略以明确引用 first_user@email.com 而不是 ${www.amazon.com:user_id} 它工作正常。
问题
- 这甚至可以使用 LWA 用户的电子邮件地址来配置它吗?
- 有没有办法在我发出请求时记录实际发生的什么参数?
我看过参考资料like this,但我不确定哪些是实际适用的。如果我能够以某种方式看到在我提出请求时会遇到什么值,那就太好了。
提前致谢。
【问题讨论】:
标签: android amazon-web-services amazon-s3 amazon-cognito