AWS Lambda JWT authenticaiton
AWS API Gateway has the ability to pre-authenticate connections prior to launching the endpoint, by passing the
authorizationToken to a Lambda function. There are clear benefits for simplifying end point security and also a reduction in duplicated code by utilising this feature. However I found the AWS examples were excessively complicated for what should be a very simple task.
So here's my example.
The main concern is that AWS Lambda authentication expects a very specific response and if that response is not given it will throw a 500 error with
x-amzn-ErrorType: AuthorizerConfigurationException in the response header if the response object is not exactly as expected.
I personally use https://zappa.io to handle the publishing part of my Lambdas, but I'll include an image of the API Gateway config.