gpt4 book ai didi

ios - 亚马逊的开发人员身份验证

转载 作者:行者123 更新时间:2023-11-29 12:05:00 25 4
gpt4 key购买 nike

我对亚马逊不太熟悉,所以有几个问题:

我想使用我自己的自定义后端解决方案通过 Cognito 为亚马逊上的用户执行登录。找到this像可能的解决方案。这个后台帮我注册登录后返回

{
identityId = "eu-xxxx-x:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx";
login = 1;
token = "eyJraWQiOiJldS13ZXN0LTExIiwidHlwIjoiSldTIiwiYWxnIjoiUlM1MTIifQ.eyJzdWIiOiJldS13ZXN0LTE6NGFmNDdmMWItZDNmOC00NmZkLWI2MzEtZGE2OGU3ZmRmYzE1IiwiYXVkIjoiZXUtd2VzdC0xOjIwNjBiZDc3LWEwNDAtNGI4OC05MDU4LTczMGY3Y2RmNGQyZSIsImFtciI6WyJhdXRoZW50aWNhdGVkIiwibG9naW4ud3A0Lm15YXBwIiwibG9naW4ud3A0Lm15YXBwOmV1LXdlc3QtMToyMDYwYmQ3Ny1hMDQwLTRiODgtOTA1OC03MzBmN2NkZjRkMmU6a2lyaWxsLmdlQGdtYWlsLmNvbSJdLCJpc3MiOiJodHRwczovL2NvZ25pdG8taWRlbnRpdHkuYW1hem9uYXdzLmNvbSIsImV4cCI6MTQ1NTI5MDA5OSwiaWF0IjoxNDU1Mjg5MTk5fQ.FGnBUEQZ3wDENFNa_g29l2UhlIAklBnLdqpMomSE3_ayesNV1dqGyzAMQCvwyr4XdJpB3lI0KF-k3wc4t8BKPYg5QKrZ-q-aNkjwp34tHFMIr8vGw4vbZiKB6XnGMRghYSbPtuwwFG80ibZMAAXik4nld8sGxoQSrCjTubPKU4I9Mzi6lJQsDGAZxmm56E2lVSeBw2nZbE1iwRDhJf6hHJsKOLceDDtWoknRX3NHeNuoueNLS1JrbphD8wVqejxhEjrK-qucoUL_uj81GxYUkyONQtu-3B79epsXIsxvU_zW1MwVufFg5p5ID83F1Cic77QkzF2FJnEJIadEG6R_yw";
}

我想关注这个guide .但根据这个,我应该提供 IdentityProviderName 和 token ,并在任何社交登录后设置它:

credentialsProvider.logins = @{
@(AWSCognitoLoginProviderKeyFacebook): token
};

作为 IdentityProviderName,我使用了在 config.json 中设置的名称

"DEVELOPER_PROVIDER_NAME": "<ProviderName>"

但我没有任何供应商,但我有异常(exception)

AWSCognitoCredentialsProvider getCredentialsWithCognito:authenticated:]_block_invoke | GetCredentialsForIdentity failed. Error is [Error Domain=com.amazonaws.AWSCognitoIdentityErrorDomain Code=8 "(null)" UserInfo={__type=InvalidParameterException, message=Please provide a valid public provider}]

当我转到 IAM 控制台创建 providerID 时,它会要求我选择提供商类型(OpenID 或 SAML)

enter image description here

所以我真的不明白到底应该放什么?选择什么类型。

对于服务器,我使用 Lambda 服务和 DynamoDB 服务,对于使用 S3 的网页。

根据 this流程:

enter image description here

我已经完成了前 4 个步骤,我在第 5 个步骤上堆叠,所以我只需要将此数据发送到 Cognito(无需准备我的自定义开发提供程序,因为我已经有 idendityID 和 token ,这看起来不正确).

结果

enter image description here

开发人员身份验证 - 仅适用于来自 lambda 的登录方法,但当我尝试使用 DynamoDB 时,用户未获得身份验证。

所有角色都已添加 - 目前我为 Unath 用户添加了临时角色

 {
"Sid": "DynamoDBPolicy",
"Effect": "Allow",
"Action": [
"dynamodb:*"
],
"Resource": [
"*"
]
}

一切正常(呵呵)但不是很好

问题 - 如何使用从放置在 Lambda 上的后端解决方案接收到的 token 创建 Cognito DevAuth?我错过了什么吗?

更新


感谢@Rachit Dhall

AWSCognitoIdentity *cognitoIdentity = [AWSCognitoIdentity defaultCognitoIdentity];
AWSCognitoIdentityGetCredentialsForIdentityInput *input = [[AWSCognitoIdentityGetCredentialsForIdentityInput alloc] init];
input.identityId = [task.result valueForKey:@"identityId"];
input.logins = @{
@"cognito-identity.amazonaws.com" : [task.result valueForKey:@"token"]
};

[cognitoIdentity getCredentialsForIdentity:input completionHandler:^(AWSCognitoIdentityGetCredentialsForIdentityResponse * _Nullable response, NSError * _Nullable error) {

//how to update my configuration for AWS with
//AWSCognitoIdentityCredentials object?
}];

但不确定如何处理响应中收到的 AWSCognitoIdentityCredentials - 如何更新我的配置?

还发现了下一个:

enter image description here

难道就没有别的办法了吗?还是遗漏了什么?

最佳答案

表示存在有效公共(public)提供程序问题的错误是因为您正在使用登录提供程序调用 GetCredentialsForIdentity。但流程是您从后端调用 GetOpenIdTokenForDeveloperIdentity,您会得到一个 token 作为响应。然后,要获取凭据,您可以调用 GetCredentialsForIdentity,在登录参数中使用键 cognito-identity.amazonaws.com,并将值作为从上次调用收到的 token 。

更新:

确保 Amazon DynamoDB uses credentials由 Amazon Cognito 提供,您可以使用凭证提供程序创建默认的 AWSServiceConfiguration 并使用它来初始化客户端。

// create a configuration that uses the provider
AWSServiceConfiguration *configuration = [AWSServiceConfiguration configurationWithRegion:AWSRegionUSEast1 provider:credentialsProvider];

// get a client with the default service configuration
AWSDynamoDB *dynamoDB = [AWSDynamoDB defaultDynamoDB];

关于ios - 亚马逊的开发人员身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35366178/

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