Set Custom Authorizer type to REQUEST (not TOKEN)

I’m setting up a service to listen to POST requests to an AWS API Gateway.

The service includes a Custom Authorizer function:

 functions:
    listen:
    handler: index.handler
    events:
          - http:
                path: /listener
                method: POST
                authorizer: authorizerFunc
  authorizerFunc:
    handler: index.authorizer

I expected the authorizerFunc to be passed the full HTTP request from AWS API Gateway, since I’m using the default lambda-proxy method. But instead the function is only receiving the Authorization header as a TOKEN.

event variable:
{
“type”: “TOKEN”,
“methodArn”: “arn:aws:execute-api:us-east-1:[REDACTED]”,
“authorizationToken”: “imatoken”
}

How can I change the custom authorizer type from TOKEN to REQUEST, so that the authorizationFunc gets the full HTTP request?

Info on TOKEN vs REQUEST type authorizers: http://docs.aws.amazon.com/apigateway/latest/developerguide/use-custom-authorizer.html#api-gateway-custom-authorizer-input

1 Like

It looks like the “TOKEN” type is hardcoded into Serverless:

This being the case, how can I get the HTTP request parameters into the Authorizer function? I’m getting the request in the run function itself, as expected due to lambda-proxy.

1 Like

I’m having the same problem.

I found this plugin and I was hopeful it would just work: https://github.com/SC5/serverless-plugin-cfauthorizer

I made the changes per the docs, but deployment would fail:

Serverless: Checking Stack update progress...
.........................
Serverless: Operation failed!

  Serverless Error ---------------------------------------

  An error occurred: myAuthorizer - URI is a required field in an Authorizer.

  Stack Trace --------------------------------------------

The AWS::ApiGateway::Authorizer docs confirm this is required.

The plugin code is very short and I suspect that one may only need to add some kind of definition around line 66-67 to add the AuthorizerUri.

But I’m very green with serverless and CloudFormation and I’m not sure how to go about making the change.

Bump.

Raised as https://github.com/serverless/serverless/issues/4325