問題描述
我已經實現了一個 AWS Lambda 函數并使用網關返回填充數據:
I have implemented a AWS Lambda function and used the gateway to return the fulling data:
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 來訪問表?
So the identityId and token get sent back to the ios device. In my device I try to connect to an AWS DynamoDB table but access is denied. How do I use the identityId and token to gain access to the tables?
我在 IAM 中為 Unauth 設置了角色,該角色拒絕 Dydnamo 和 Auth,后者通過其策略授予對表的訪問權限.
I have set up roles in IAM for Unauth which denies Dydnamo and Auth which gives access to the tables through its policies.
我正在嘗試使用以下方式實現身份驗證:http://docs.aws.amazon.com/cognito/latest/developerguide/authentication-flow.html
I am trying to implement authentication using: http://docs.aws.amazon.com/cognito/latest/developerguide/authentication-flow.html
我看到有兩個流程,基本流程和增強流程.文檔說大多數用戶將使用增強的流程并實現 GetCredentialForIdentity.
I see there are two flows which are Basic and Enhanced. The documentation says most users will use the enhanced flow and that implements GetCredentialForIdentity.
這是如何在我的 ios 代碼中實現的,以便我可以將我的角色從 unauth 切換到 auth 并可以訪問 dynamodb?這種訪問會持續多久?我想在我的 ios 代碼中完成這一切,而不是使用 lambda 或其他類似的東西.
How is that implemented in my ios code so that I can switch my role from unauth to auth and can access to dynamodb? How long will this access last? I would like to do this all in my ios code instead of using lambda or something else like that.
推薦答案
如果您的用戶未經身份驗證,那么您需要在登錄時清除您的憑據,并且您的登錄"方法現在應該返回正確更新的登錄映射.
If your user is unauthenticated, then logs in you need to clear your credentials, and your 'logins' method should now return a properly updated logins map.
以下是可幫助您的文檔:http://docs.aws.amazon.com/cognito/latest/developerguide/developer-authenticated-identities.html
Here is the documentation to help you: http://docs.aws.amazon.com/cognito/latest/developerguide/developer-authenticated-identities.html
這篇關于使用 AWS Cognito 開發人員身份從我的 ios 應用程序獲得對 DynamoDB 的完全訪問權限的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!