如何解决Serverless framework 3中的授权人问题



当我使用Serverless framework 2时,我以如下方式定义authorizer。

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

但是它在Serverless框架3中不受支持。现在,我得到以下错误。

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

我看了他们不赞成的文档,但我找不到解决方案。如何解决这个问题?

似乎serverless希望您为AWS REST API 定义HttpAuthorizer而不是Lambda Authorizer

设置的定义如下:https://raw.githubusercontent.com/lalcebo/json-schema/master/serverless/reference.json

Rest API(V1(实际上更高级。请参阅:https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/AWS_ApiGateway.html或https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/AWS_ApiGatewayV2.html

检查以下文档:https://serverless.com/framework/docs/providers/aws/events/apigateway#http-具有自定义授权程序的端点

授权人声明必须在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

最新更新