Infra类似于具有处理程序Lambda函数的API Gateway。我们已经为3个客户端创建了3个IAM用户,客户端通过提供访问和密钥来执行API网关。我想获取访问权限和密钥来识别用户。下面的代码(在lambda中)帮助我们获取用户详细信息。
AWSCredentialsProvider credProvider = new AWSStaticCredentialsProvider(new BasicAWSCredentials("accessKey","secretKey"))
AmazonIdentityManagementClientBuilder.standard().withCredentials(credProvider).build()如何获取访问权限和密钥?处理函数中的上下文对象仅提供认知身份对象,但我一直期望在api调用过程中使用具有访问权限和密钥的IAM身份对象。
发布于 2020-12-04 15:14:53
实施RequestHandler<APIGatewayProxyRequestEvent, APIGatewayProxyResponseEvent>。对于每个传入的请求事件,您将在APIGatewayProxyRequestEvent中获得以下详细信息
requestEvent.getRequestContext().getIdentity() 包含
private String cognitoIdentityPoolId;
private String accountId;
private String cognitoIdentityId;
private String caller;
private String apiKey;
private String sourceIp;
private String cognitoAuthenticationType;
private String cognitoAuthenticationProvider;
private String userArn;
private String userAgent;
private String user;
private String accessKey;如您所见,您将在userARN中获得userID以及accessKey。
https://stackoverflow.com/questions/63582305
复制相似问题