简体   繁体   English

无服务器框架自定义 lambda 授权器未被触发

[英]Serverless Framework custom lambda authorizer is not being triggered

So I am using the Serverless Framework and the custom lambda authorizer is not being triggered.所以我使用的是无服务器框架,并且没有触发自定义 lambda 授权器。 When I check the function that should be authorized, the API Gateway console says it has no authorization.当我检查应该授权的功能时,API网关控制台说它没有授权。 I also can't find my authorization function under Authorizers.我也无法在 Authorizers 下找到我的授权功能。 Any pointers would be appreciated.任何指针将不胜感激。

loginUser:
    handler: loginUser.loginUser
    module: src/functions/loginFunction
    events:
      - http:
          path: /user/login
          method: post
          request:
            schema:
              application/json: ${file(src/schema/loginUser_request.json)}

  getCats:
    handler: catCrud.getCats
    module: src/functions/catCrud
    events:
      - http: 
          path: /cat
          method: get
          authoirzer:
            name: authorizeFunc
            identitySource: method.request.header.Authorization
            type: token
  authorizeFunc:
    handler: authorizeFunc.authorizeFunc
    module: src/functions/loginFunction

PS I am not sure if this is of any value, but I am using the serverless-python-requirements for packaging up my lambdas and the authorizeFunc is sharing the same module with the loginFunction because they have the same libs. PS 我不确定这是否有任何价值,但我使用 serverless-python-requirements 来打包我的 lambdas,并且 authorizeFunc 与 loginFunction 共享相同的模块,因为它们具有相同的库。

You misspelled authorizer in the events section of your serverless.yml .您在serverless.ymlevents部分拼错了authorizer

Try:尝试:

  getCats:
    handler: catCrud.getCats
    module: src/functions/catCrud
    events:
      - http: 
          path: /cat
          method: get
          authorizer:
            name: authorizeFunc
            identitySource: method.request.header.Authorization
            type: token

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无服务器:使用自定义授权者部署端点-找不到名称错误 - Serverless: Deploy Endpoint with Custom Authorizer - Name Not Found Error 使用无服务器框架的AWS Codebuild Golang Lambda - AWS Codebuild Golang Lambda using Serverless Framework AWS API Gateway定制授权者。 如何在Lambda中访问principalId - AWS API Gateway custom authorizer. How to access principalId in lambda 无法在AWS Lambda自定义授权者中验证Twilio请求 - Cannot Validate Twilio Request in an AWS Lambda Custom Authorizer 从自定义授权方 Lambda 函数访问 POST 请求正文 - Access POST Request body from Custom Authorizer Lambda Function 无法通过Lambda函数访问SQS队列消息-无服务器框架 - Cannot access SQS queue message through Lambda function - Serverless framework 使用 API 网关和无服务器框架在 AWS Lambda 上超过了速率 - Rate Exceeded on AWS Lambda Using API Gateway and serverless framework 如何使用无服务器框架将参数传递给 schedule.Net lambda 函数? - How to pass parameters to scheduled .Net lambda functions using serverless framework? 使用无服务器框架为 AWS Lambda 构建和使用本地包 - Build and use local package for AWS Lambda using serverless framework 未应用自定义 lambda 表达式 - Custom lambda expression not being applied
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM