我是否可以将策略应用于AWS DynamoDB表,但是根据访问它的用户的Cognito ID对其进行限制?
例如,Customer表的主哈希密钥等于Cognito ID.当除了共享相同ID的用户之外的任何人试图获得该项目时,他们将收到未经授权的例外.
(非DynanoDB策略可能也有效.)
我正在使用Amazon SNS和Amazon Cognito服务在iOS应用程序中实现推送通知.Cognito成功保存令牌,我的应用程序得到通知,一切正常,但有一件事.
现在,当仍处于开发阶段时,我需要手动将端点添加到SNS主题,因此所有订阅者都可以收到通知.当我将更新推送到App Store时,将会有数千个令牌添加.
我正在研究亚马逊AWS文档,但不知道是否可以在没有额外努力的情况下实现它.
我的问题:是否可以自动将端点订阅到仅包含Amazon服务的主题?
push-notification amazon-web-services amazon-sns ios amazon-cognito
我正在尝试在我的iOS(Swift)应用程序中实现新的AWS Cognito用户池,但我很难让登录过程工作.我基本上试图遵循这里提供的示例.
这是我到目前为止:
AppDelegate中:
class AppDelegate: UIResponder, UIApplicationDelegate, AWSCognitoIdentityInteractiveAuthenticationDelegate {
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
let serviceConfiguration = AWSServiceConfiguration(region: AWSRegionType.USEast1, credentialsProvider: nil)
AWSServiceManager.defaultServiceManager().defaultServiceConfiguration = serviceConfiguration
let configurationUserPool = AWSCognitoIdentityUserPoolConfiguration(
clientId: "###",
clientSecret: "#########",
poolId: "###")
AWSCognitoIdentityUserPool.registerCognitoIdentityUserPoolWithConfiguration(serviceConfiguration, userPoolConfiguration: configurationUserPool, forKey: "UserPool")
self.userPool = AWSCognitoIdentityUserPool(forKey: "UserPool")
self.userPool!.delegate = self
return true
}
func startPasswordAuthentication() -> AWSCognitoIdentityPasswordAuthentication {
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let logInNavigationController = mainStoryboard.instantiateViewControllerWithIdentifier("LogInNavigationController") as! UINavigationController
dispatch_async(dispatch_get_main_queue(), {
self.window?.rootViewController = …Run Code Online (Sandbox Code Playgroud) 在使用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
有没有办法在Amazon Cognito用户池中对用户强制实施密码过期策略?
如何使用AWS SAM创建API,使用Cognito User Pools授权程序进行授权?
Theres AWS :: ApiGateway :: Authorizer.但......
{
"Type" : "AWS::ApiGateway::Authorizer",
"Properties" : {
"AuthorizerCredentials" : String,
"AuthorizerResultTtlInSeconds" : Integer,
"AuthorizerUri" : String,
"IdentitySource" : String,
"IdentityValidationExpression" : String,
"Name" : String,
"ProviderARNs" : [ String, ... ],
"RestApiId" : String,
"Type" : String
}
}
Run Code Online (Sandbox Code Playgroud)
它看起来像RestApiId是指使用此授权程序的API?但是使用AWS SAM,我的API被定义为
Resources:
Ec2Index:
Type: AWS::Serverless::Function
Properties:
Handler: ec2/index.handler
Runtime: nodejs6.10
CodeUri: ./src
FunctionName: 'ApiEc2IndexHandler'
Description: 'List EC2 resources'
Timeout: 30
Role: 'arn:aws:iam::598545985414:role/awsmanagement-lambda-management'
Events:
Ec2Index:
Type: …Run Code Online (Sandbox Code Playgroud) 只是阅读文档,它们看起来与我非常相似,所以我无法真正辨别为什么使用一个而不是另一个.虽然身份令牌看起来更好,因为它在用户池中具有自定义属性(例如:custom:blah和默认值,如name和email).
现在,我正在使用一个将访问令牌传递回浏览器的应用程序,以便它可以使用它来进行ajax REST调用(有一个auth过滤器需要此访问令牌并验证它).我可以用id令牌切换访问令牌吗?当前的验证逻辑是sub从访问令牌中获取字段(uuid),但是该sub字段也存在于身份令牌中(以及除了aud我不需要的其他所有其他属性).我只是想确保我理解这一点,因为令我困惑的是为什么两个令牌都存在并且看起来如此相似.
似乎无法调用通过CloudFront分配启用AWS_IAM保护的REST API.
以下是如何重现这个:
现在使用经过身份验证的用户(我使用Cognito UserPool用户和aws-amplify)来调用
我得到的错误是:
{"message":"我们计算的请求签名与您提供的签名不匹配.请检查您的AWS秘密访问密钥和签名方法.有关详细信息,请参阅服务文档."}
我无法相信AWS不支持自定义域后面的AWS_IAM受保护端点,因为这必须是一个非常常见的用例.
因此,请您提供一份如何实现这一目标的详细清单?
谢谢
amazon-cloudfront amazon-cognito aws-sdk aws-api-gateway aws-amplify
我正在尝试使用DynamoDB和Cognito创建一个多租户应用程序.文档非常清楚如何实现细粒度授权,以便用户只能通过向IAM访问策略添加条件来访问自己的记录,如下所示:
"Condition": {
"ForAllValues:StringEquals": {
"dynamodb:LeadingKeys": [
"${cognito-identity.amazonaws.com:sub}"
]
}
}
Run Code Online (Sandbox Code Playgroud)
当Cognito用户id是行的哈希键时,这非常适合允许用户读写自己的记录,但我正在努力解决如何允许其他用户只读访问某些记录的问题.
以一个有多个课程的学生的模型为例:
{
“student_id”: “ABC-1234567”,
“course_name”: “Statistics 101”,
“tutors”: [“Cognito-sub-1”, “Cognito-sub-2”],
“seminar_reviews”: [
{
“seminar_id”: “XXXYYY-12345”
“date”: “2018-01-12”,
“score”: “8”,
“comments”: “Nice class!”
},
{
“seminar_id”: “ABCDEF-98765”
“date”: “2018-01-25”,
“score”: “3”,
“comments”: “Boring.”
}
]
}
Run Code Online (Sandbox Code Playgroud)
(Cognito-sub-1是导师的Cognito id)
通过将上述策略条件应用于用户的IAM角色,用户可以读取和写入此文档,因为散列键(student_id)是用户的Cognito id.
我也希望文档中列出的导师具有对某些属性的只读访问权限,但我找不到任何如何完成此操作的示例.我知道我不能使用dynamodb:LeadingKeys条件因为教师不是表的哈希键.如果我设置使用导师列表作为哈希键的全局二级索引(GSI),是否可以这样做?
如果可以使用索引完成此操作,我认为这只允许对该索引的读访问(因为索引不允许写操作).是否有任何替代方法允许基于非散列键的属性进行写访问?
或者,我可以使用更长的字符串作为散列键,连接类似的属性”owner”:以及”read-only”:包含Cognito ID列表的属性,并在我的策略中使用它来创建仅基于散列键的更细粒度的权限模型吗?这假定策略可以解码字符串中的列表,因为DynamoDB不允许散列键是列表,JSON对象或类似物.
我无法找到任何考虑细粒度访问控制的资源,除了允许用户只读取/写入自己的记录,所以如果有人可以指导我,那将是一个很好的开始.
multi-tenant amazon-web-services amazon-dynamodb amazon-cognito aws-iam
我正在尝试创建一个Android项目,在该项目中,我可以通过使用户在浏览器中登录Amazon Cognito来授权用户,然后该用户应重定向回我的应用程序。不幸的是,当浏览器打开时,没有到达正确的登录页面,而是不断出现此错误:
在我的AuthenticatorActivity.java中:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_authenticator);
Uri authzUrl = Uri.parse("https://<myDomain>.auth.us-west-2.amazoncognito.com/login?response_type=token&client_id=<myClientId>&redirect_uri=myapp://mainAct");
Intent launchBrowser = new Intent(Intent.ACTION_VIEW, authzUrl);
startActivity(launchBrowser);
}
Run Code Online (Sandbox Code Playgroud)
在AndroidManifest中:
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:host="mainAct" android:scheme="myapp"></data>
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
我无法弄清楚我在做什么错。我错过了一步吗?
amazon-cognito ×10
ios ×2
amazon-iam ×1
amazon-sns ×1
android ×1
aws-amplify ×1
aws-cognito ×1
aws-iam ×1
aws-sdk ×1
httprequest ×1
jwt ×1
multi-tenant ×1
oauth ×1
redirect ×1