AWS API Gateway does not include the event.requestContext.authorizer field if there is no authorizer configured for the function.
This PR deletes the event.requestContext.authorizer field if the function does not have an authorizer.
Motivation and Context
I'm doing serialization of API Gateway in Golang
It was failing because the authorizer payload didn't match what it expected
Upon further investigation, I found that serverless-offline was always setting event.requestContext.authorizer if a Bearer token comes through in the HTTP Authorization headers.
My solution is to simply remove event.requestContext.authorizer if the lambda function does not have an authorizer set.
How Has This Been Tested?
I've written tests and included them in this PR. Please let me know if you want me to kick the tires in any other ways!
Description
AWS API Gateway does not include the
event.requestContext.authorizer
field if there is noauthorizer
configured for the function.This PR deletes the
event.requestContext.authorizer
field if the function does not have an authorizer.Motivation and Context
authorizer
payload didn't match what it expectedserverless-offline
was always settingevent.requestContext.authorizer
if aBearer
token comes through in the HTTP Authorization headers.event.requestContext.authorizer
if the lambda function does not have anauthorizer
set.How Has This Been Tested?
I've written tests and included them in this PR. Please let me know if you want me to kick the tires in any other ways!