in auth_function/app.py [0:0]
def lambda_handler(event, context):
print(event)
print("Method ARN: " + event['methodArn'])
apiKey = event['queryStringParameters']['apiKey']
principalId = "user|a1b2c3d4"
tmp = event['methodArn'].split(':')
apiGatewayArnTmp = tmp[5].split('/')
awsAccountId = tmp[4]
policy = AuthPolicy(principalId, awsAccountId)
policy.restApiId = apiGatewayArnTmp[0]
policy.region = tmp[3]
policy.stage = apiGatewayArnTmp[1]
policy.allowMethod('GET', '/auth')
authResponse = policy.build()
context = {
'SomeKey': 'SomeValue'
}
usageIdentifierKey = apiKey
authResponse['context'] = context
authResponse['usageIdentifierKey'] = usageIdentifierKey
print(authResponse)
return authResponse