简体   繁体   English

如何解决无服务器框架 3 中的授权问题?

[英]How to solve authorizer issue in Serverless framework 3?

When I use Serverless framework 2, I defined authorizer like the below way.当我使用 Serverless 框架 2 时,我像下面这样定义了 authorizer。

sample:
  handler: sample.handler
  events:
    - http:
        path: sample
        method: get
        cors: true
        authorizer: verify-token

But It's not supported in Serverless framework 3. Now, I am getting the below error.但无服务器框架 3 不支持它。现在,我收到以下错误。

Incorrect type. Expected "Aws.HttpAuthorizer".yaml-schema: Serverless Framework Configuration

I looked at their deprecated doc But I don't find the solution.我查看了他们已弃用的文档,但没有找到解决方案。 How can resolve this issue?如何解决这个问题?

just curious if anyone has found an answer for this?只是好奇是否有人找到了答案?

Incorrect type.类型不正确。 Expected "Aws.HttpAuthorizer".应为“Aws.HttpAuthorizer”。

Seems like serverless expects you to define HttpAuthorizer instead of Lambda Authorizer for AWS REST API似乎无服务器希望您定义 HttpAuthorizer 而不是 Lambda Authorizer for AWS REST API

Definitions of the settings are here: https://raw.githubusercontent.com/lalcebo/json-schema/master/serverless/reference.json设置的定义在这里: https://raw.githubusercontent.com/lalcebo/json-schema/master/serverless/reference.json

Rest API (V1) is actually more advanced. Rest API(V1)其实更高级。 see: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/AWS_ApiGateway.html or https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/AWS_ApiGatewayV2.html请参阅: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/AWS_ApiGateway.htmlhttps://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/AWS_ApiGatewayV2.8854178646

Check the following documentation: https://serverless.com/framework/docs/providers/aws/events/apigateway#http-endpoints-with-custom-authorizers检查以下文档: https://serverless.com/framework/docs/providers/aws/events/apigateway#http-endpoints-with-custom-authorizers

The authorizer declaration must be completed in v3:授权方声明必须在 v3 中完成:

sample:
  handler: sample.handler
  events:
    - http:
        path: sample
        method: get
        cors: true
        authorizer:
          arn: xxx:xxx:verify-token
          managedExternally: false
          resultTtlInSeconds: 0
          identitySource: method.request.header.Authorization
          identityValidationExpression: someRegex

暂无
暂无

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

相关问题 如何使用 Serverless Framework 管理 Lambda 内部的 Aurora Serverless 数据 api 的 typeORM 连接 - How to manage typeORM connection of Aurora Serverless data api inside Lambda using Serverless Framework 使用无服务器框架的 Lambda Snapstart - Lambda Snapstart with Serverless framework 如何使用无服务器框架创建 API 的新版本? - How do you create a new version of an API using serverless framework? 如何使用无服务器框架为 API 网关设置描述? - How to set a description for an API Gateway using the Serverless Framework? 如何在 Serverless Framework 中分配 function 级别的 IamRoleStatements? - How do I assign function level IamRoleStatements in Serverless Framework? 如何使用 AWS 的无服务器框架获取最新的 Layer 版本 Lambda - How to get latest Layer version with serverless framework for AWS Lambda 如何使用 Serverless Framework 在多个区域部署堆栈? - how to deploy a stack in multiple regions using the Serverless Framework? 如何使用 serverless.io 框架和 serverless.yml 文件将整数作为变量传递给 aws-step-function 中的等待状态类型 - How to Pass integer as variable to Wait Type of State in aws-step-function using serverless.io framework and the serverless.yml file 使用无服务器框架请求验证 - Request validation using serverless framework 使用无服务器框架在 lambda AWS 中授予授权代码 - Authorization code grant in lambda AWS with Serverless Framework
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM