AWS API 网关:将结果策略从 Lambda 身份验证器转发到后端

AWS API Gateway: Forward Result Policy From Lambda Authenticator to Backend

我正在使用自定义身份验证器 (Lambda) 验证 Javascript Web 令牌 (JWT) 用于亚马逊 API 网关上的后端 Node.js API。

有没有办法通过 header 将 Lambda 生成的策略传递到后端 API? JWT 包含一些我希望 API 后端访问的信息,而无需 re-validate 令牌。

更新:您可以使用 docs

中提到的 principalId

You can access the principalId value in a mapping template using the $context.authorizer.principalId variable. This is useful if you want to pass the value to the back end. For more information, see Accessing the $context Variable.