How to configure serverless framework HttpApi Authorizer for custom lambda authorizer

Viewed 904

In the documentation there is information on how to configure authorizers such as Cognito:

https://www.serverless.com/framework/docs/providers/aws/events/http-api#jwt-authorizers

And here is a copy of it:

  httpApi:
    authorizers:
      someJwtAuthorizer:
        identitySource: $request.header.Authorization
        issuerUrl: https://cognito-idp.${region}.amazonaws.com/${cognitoPoolId}

Does anyone know how to configure for custom lambda jwt authorizer I have coded myself?

2 Answers

I only achieved it using a previously created JWT Authorizer for httpApi, but must be similar with a custom Lambda Authorizer (never used one)

      - httpApi:
          method: any
          authorizer: # https://github.com/serverless/serverless/issues/7598
            # Provide both type and authorizerId
            type: COGNITO_USER_POOLS # TOKEN or REQUEST or COGNITO_USER_POOLS, same as AWS Cloudformation documentation
            id: <AUTHORIZER ID>  # or authorizer name "name: my-lambda"
            scopes: # Optional - List of Oauth2 scopes when type is COGNITO_USER_POOLS
              - my-resource-server/my-grant-type
          path: /{proxy+}

More on this issue here:

AWS HTTP API: Support IAM and Lambda authorizers #8210

feat(AWS HTTP API): Add support for custom Lambda authorizers #9192

Related