amazon-web-services - 如何为 IAM 角色策略模板使用 Cognito 自定义属性
问题描述
在多租户设置中,我需要根据 Congito 自定义属性限制对 S3 存储桶的访问custom:orgId
。
到目前为止完成:
- 向用户池添加了自定义属性:
custom:orgId
- 授予 App Client 读取自定义属性权限
- 在 Identity Pool > Authentication Providers > Cognito > Attributes for access control 中配置了自定义属性映射:
Tag key for principal: orgId
,Attribute name: custom:orgId
- 承担角色政策
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Federated": "cognito-identity.amazonaws.com"
},
"Action": [
"sts:AssumeRoleWithWebIdentity",
"sts:TagSession"
],
"Condition": {
"StringEquals": {
"cognito-identity.amazonaws.com:aud": "us-east-1:3498beea-a45e-4b5a-xxx-yyy"
},
"ForAnyValue:StringLike": {
"cognito-identity.amazonaws.com:amr": "authenticated"
}
}
}
]
}
- 角色政策:
{
"Effect": "Allow",
"Action": "s3:ListBucket",
"Resource": "arn:aws:s3:::restricted",
"Condition": {
"StringLike": {
"s3:prefix": [
"${aws:PrincipalTag/orgId}/*"
]
}
}
}
我代表经过身份验证的用户(使用 Amplify)获取 STS 会话并尝试列出存储桶。我收到 403 错误。
- 我在这个设置中缺少什么?
- 如何调试/确保 STS 会话请求包含
aws:PrincipalTag/orgId
解决方案
推荐阅读
- scala - Scala:类型推断问题
- c# - 尝试发送确认电子邮件时,Identity EmailService 未触发
- .net - .NET 覆盖表单文本属性
- ruby-on-rails - Rails:返回有限数量的记录以及第一个
- mysql - 当它不是输入值时,在前端更新后保存更新的表值,Laravel
- typescript - 在没有判别式的情况下缩小打字稿中的条件类型
- c++ - 为什么使用 std::vector::push_back 的移动变体会调用被移动项目的复制构造函数?
- java - 使用spring jpa将sql查询结果映射到java对象(在非实体类中)
- angularjs - 在服务调用中获取 AngularJS 1 中的状态码
- python - PyMongo:批量插入新集合时的 NatType ValueError