【发布时间】:2020-02-18 21:32:18
【问题描述】:
我的用户通过连接到 cognito 的微服务登录到我的应用程序(请求通过 API 网关代理)
他们得到一个会话令牌。
登录后,他们需要将一些文件放入 S3。
我想使用 STS 为他们提供临时凭据,但要调用 sts.AssumeRoleWithWebIdentity 我需要一个网络身份令牌。
如何获取带有会话令牌作为输入的 Web 身份令牌?
我编写了一个临时 lambda(节点),它在使用用户名和密码登录时返回 STS 凭据:
const cognitoidentityserviceprovider = new AWS.CognitoIdentityServiceProvider();
const cognitoidentity = new AWS.CognitoIdentity();
cognitoidentityserviceprovider.initiateAuth(...) //AuthFlow: 'USER_PASSWORD_AUTH'
cognitoidentity.getId(...)
cognitoidentity.getCredentialsForIdentity(...)
登录和文件上传之间可能有一段时间,我不希望用户每次都提交用户名/密码。也没有 AuthFlow 接受会话令牌。
我猜 API 网关可能会返回一些有用的东西,但我在文档中没有找到任何东西: https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html#context-variable-reference
【问题讨论】:
标签: amazon-web-services go aws-sts