在使用Cognito用户池登录时,我无法理解如何在DynamoDB上使用细粒度访问控制.我跟着文档和谷歌搜索,但由于某种原因我似乎无法让它工作.
我的AWS设置如下所示.如果我删除角色策略中的条件,我可以获取并放置项目没有问题,所以似乎条件是问题.但我无法弄清楚如何或在何处调试依赖于经过身份验证的身份的策略 - 可用的变量,它们的值是什么等等.
任何帮助将不胜感激!
DynamoDB表
DynamoDB示例行
{
"attributes": {},
"docID": "0f332745-f749-4b1a-b26d-4593959e9847",
"lastModifiedNumeric": 1470175027561,
"lastModifiedText": "Wed Aug 03 2016 07:57:07 GMT+1000 (AEST)",
"type": "documents",
"userID": "4fbf0c06-03a9-4cbe-b45c-ca4cd0f5f3cb"
}
Run Code Online (Sandbox Code Playgroud)
Cognito用户池用户
"RoleName"的角色策略
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"dynamodb:GetItem",
"dynamodb:PutItem"
],
"Resource": [
"arn:aws:dynamodb:ap-southeast-2:NUMBER:table/documents"
],
"Condition": {
"ForAllValues:StringEquals": {
"dynamodb:LeadingKeys": [
"${cognito-identity.amazonaws.com:sub}"
]
}
}
}
]
}
Run Code Online (Sandbox Code Playgroud)
从cognitoUser.getUserAttributes()返回的登录信息
attribute sub has value 4fbf0c06-03a9-4cbe-b45c-ca4cd0f5f3cb
attribute email_verified has value true
attribute email has …Run Code Online (Sandbox Code Playgroud) amazon-web-services amazon-dynamodb amazon-iam amazon-cognito