我有一个由API Gateway触发的AWS Python lambda。 API网关调用是使用Cognito授权的。
我想在Cognito中为授权用户定义一个自定义属性。
目前在“ requestContext”中,我正在接收:
authorizer': {'claims': {'aud': '4m3ak7fsqva7kokbkfl2vev6420',
'auth_time': '156074111',
'cognito:username': 'fa15f3d8-220b-4c5c-b5a6-XXXXXXXXXX',
'email': 'email@address.com',
'email_verified': 'false',
'event_id': '12345-7326-4fef-95cd-ae06665169a7',
'sub': 'fd1666d8-260b-4c1c-a5b6-466d4b42bd77',
'token_use': 'id'}},
这很棒,但是用户是UserPool的一部分,该用户池已定义了自定义属性:
自定义属性custom:customid
如何通过API Gateway / Cognito获取“ customid”传递给lambda,理想情况下是使用AWS SAM,因为这是lambda的定义方式。
template.yaml
ApiGatewayApi:
Type: AWS::Serverless::Api
Properties:
StageName: dev
Cors: "'*'"
Auth:
DefaultAuthorizer: CognitoAuthorizer
Authorizers:
CognitoAuthorizer:
UserPoolArn: !GetAtt CognitoUserPool.Arn
我在这里找到了一个类似的问题:Retrieve data from AWS Cognito using Boto3,但是很难将其添加到SAM模板中