gpt4 book ai didi

ios - 使用 AWS Cognito 开发人员身份从我的 iOS 应用程序获得对 DynamoDB 的完全访问权限

转载 作者:技术小花猫 更新时间:2023-10-29 11:23:27 24 4
gpt4 key购买 nike

我已经实现了 AWS Lambda 函数并使用网关返回填充数据:

var param =
{
IdentityPoolId: "actualIdentityPoolId",
Logins: {} // To have provider name in a variable
};
param.Logins["com.testing.userLogin"] = userId;

cognitoidentity.getOpenIdTokenForDeveloperIdentity(param,
function(err, data)
{
if (err) return fn(err); // an error occurred
else fn(null, data.IdentityId, data.Token); // successful response
});

所以 identityId 和 token 被发送回 ios 设备。在我的设备中,我尝试连接到 AWS DynamoDB 表,但访问被拒绝。如何使用 identityId 和 token 来访问表?

我在 IAM 中为 Unauth 设置了角色,它拒绝 Dydnamo 和 Auth,后者通过其策略提供对表的访问权限。

我正在尝试使用以下方式实现身份验证:http://docs.aws.amazon.com/cognito/latest/developerguide/authentication-flow.html

我看到有两个流程,分别是基本流程和增强流程。该文档说大多数用户将使用增强的流程并实现 GetCredentialForIdentity。

它是如何在我的 ios 代码中实现的,以便我可以将我的角色从 unauth 切换到 auth 并可以访问 dynamodb?此访问将持续多长时间?我想在我的 ios 代码中完成这一切,而不是使用 lambda 或其他类似的东西。

最佳答案

如果您的用户未经身份验证,则登录时您需要清除您的凭据,并且您的“登录”方法现在应该返回正确更新的登录映射。

以下是可以帮助您的文档: http://docs.aws.amazon.com/cognito/latest/developerguide/developer-authenticated-identities.html

关于ios - 使用 AWS Cognito 开发人员身份从我的 iOS 应用程序获得对 DynamoDB 的完全访问权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41520123/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com