如何配置serverless.yml以允许端点读取授权令牌并将其发送到lambda函数以处理此函数中的授权?我只想比较Authorization令牌和硬编码值。我尝试使用自定义授权者:
custom:
authorizer:
users:
name: authorizer
type: TOKEN
identitySource: method.request.header.Authorization
identityValidationExpression: ^(.{64}$)
functions:
authorizer:
environment:
PASS_PHRASE: "DB886057AEAFF1BC44136561940B40146B77BB39AD8DC7EBB20AEF6E25A6CB93"
handler: src/handler.authorize
recource:
handler: src/handler.handle
events:
- http:
path: /recource
method: get
cors: true
authorizer: ${self:custom.authorizer.users}
- http:
path: /recource
method: options
cors: true
documentation:
description: "Options"
但不起作用。我收到:
{
"message": "Authorization header requires 'Credential' parameter. Authorization header requires 'Signature' parameter. Authorization header requires 'SignedHeaders' parameter. Authorization header requires existence of either a 'X-Amz-Date' or a 'Date' header. Authorization=DB886057AEAFF1BC44136561940B40146B77BB39AD8DC7EBB20AEF6E25A6CB93"
}