[英]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.html或https://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.