Hi all,
I’m trying to setup a custom request authorizer and I’m following the documentation located here, but my project keeps failing whenever I try to deploy.
It looks like my cloud formation template keeps trying to use a token authorizer and is failing because I don’t specify an audience, which shouldn’t be required for a request authorizer according to the docs. This seems to be an issue with the framework and not my specific config. Is there something obvious I’m missing or should I raise a bug request on GitHub? Thanks!
Serverless Version:
"serverless": "2.52.0",
My authorizer setup:
provider:
httpApi:
authorizers:
customBasicAuthorizer:
type: request
functionName: authorizerFunc
enableSimpleResponses: true
payloadVersion: '2.0'
identitySource: $request.header.Authorization
An example function using the custom authorizer (with certain values omitted):
functions:
*****:
handler: handler.*****
events:
- httpApi:
method: POST
path: *****
authorizer:
name: customBasicAuthorizer
Serverless Error Thrown:
Error: The CloudFormation template is invalid: [/Resources/HttpApiAuthorizerCustomBasicAuthorizer/Type/JwtConfiguration/Audience/0] 'null' values are not allowed in templates
at /usr/local/lib/node_modules/serverless/lib/plugins/aws/deploy/lib/validateTemplate.js:20:13
at tryCatcher (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:547:31)
at Promise._settlePromise (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:604:18)
at Promise._settlePromise0 (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:649:10)
at Promise._settlePromises (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:725:18)
at _drainQueueStep (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:93:12)
at _drainQueue (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:86:9)
at Async._drainQueues (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:102:5)
at Immediate.Async.drainQueues [as _onImmediate] (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:15:14)
at processImmediate (internal/timers.js:461:21)
Relevant Portion of my CF template that gets generated:
"HttpApiAuthorizerCustomBasicAuthorizer": {
"Type": "AWS::ApiGatewayV2::Authorizer",
"Properties": {
"ApiId": {
"Ref": "HttpApi"
},
"AuthorizerType": "JWT",
"IdentitySource": [
"$request.header.Authorization"
],
"JwtConfiguration": {
"Audience": [
null
]
},
"Name": "customBasicAuthorizer"
}
},