serverless / examples

Serverless Examples – A collection of boilerplates and examples of serverless architectures built with the Serverless Framework on AWS Lambda, Microsoft Azure, Google Cloud Functions, and more.
https://www.serverless.com/examples/
Other
11.43k stars 4.47k forks source link

Error on deploy with JWT custom authorizer #551

Open nikoskip opened 4 years ago

nikoskip commented 4 years ago

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!

joaodfmota commented 3 years ago

Currently the only way to restrict access to configured HTTP API endpoints is by setting up an JWT Authorizers. LINK