serverless / serverless/examples

Error on deploy with JWT custom authorizer

Open
#551 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
11.5k
Forks
4.4k
Avg merge
2h 55m
Merged PRs (30d)
3

Description

Hi!

I'm trying to achieve something like this guide: https://github.com/serverless/examples/tree/master/aws-node-auth0-custom-authorizers-api

But when I try to deploy I'm getting this error: Event references not configured authorizer 'authorize'.

I think the only difference is that I'm using httpApi instead of http. This is my configuration:

service: xxxx

frameworkVersion: ">=1.78.0 <2.0.0"

plugins:
  - serverless-dotenv-plugin
  - serverless-offline

provider:
  name: aws
  runtime: nodejs12.x
  region: ${env:AWS_LAMBDA_REGION}
  stage: ${ opt:stage, 'local' }
  cors:
    allowedOrigins:
      - "*"

custom:
  serverless-offline:
    httpPort: ${env:LOCAL_HTTP_PORT}
    host: 0.0.0.0
    # Enables hot reloading (https://github.com/dherault/serverless-offline/issues/864#issuecomment-627419266)
    useChildProcesses: true

functions:
  jwt-auth:
    handler: handler.jwt

  module-activation-sns:
    handler: handler.sns
    events:
      - sns: ${env:AWS_SNS_ARN_MODULE_ACTIVATION}
  
  module-activation-http:
    handler: handler.http
    events:
      - httpApi:
          method: POST
          path: /module
          authorizer: jwt-auth

Thanks!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the httpApi event and jwt-auth function in the shown service configuration, then compare their authorizer setup with the linked Auth0 custom-authorizer example. Check the Serverless Framework configuration expected for HTTP API authorizers; done means the service deploys successfully and the /module route uses the JWT authorizer.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, javascript, node.js
Domain
api, backend, cloud
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.