I am trying to protect a lambda function using a custom authorizer (which validates a jwt) on AWS API Gateway. I also want to pass any queryStringParameters
into my lambda function, so I want to keep my Integration request to be Lambda Proxy.
The custom authorizer is set, tested and working
Problem:
When I call this endpoint (after deploying), I receive a HTTP 500
response.
{
"message": "Internal server error"
}
When I remove my custom authorizer OR deselect the lambda Proxy integration, I receive a normal output from my lambda
def lambda_handler(event, context):
return {
'status': 400,
'body' : json.dumps('hello World'),
'headers': {
'Access-Control-Allow-Origin': "*"
},
'isBase64Encoded': 'false'
}
Has anyone come across this? AWS documentation on this issue is sparse :/
Thank you!
def handler(event, context): token = event['authorizationToken'].split(' ')[1] audience = {hidden} certificateFile = open("hidden",'r') certificateLines = certificateFile.readlines() certificate = ''.join(certificateLines) try: decoded = jwt.decode(token, publicKey, algorithms='RS256', audience=audience) return generatePolicy(decoded['sub'], 'Allow') except: return generatePolicy(None, 'Deny')
– Saif Elkholy