Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 路径参数,在aws lambda中使用授权程序时正文为null_Node.js_Amazon Web Services_Aws Lambda_Aws Api Gateway_Serverless Framework - Fatal编程技术网

Node.js 路径参数,在aws lambda中使用授权程序时正文为null

Node.js 路径参数,在aws lambda中使用授权程序时正文为null,node.js,amazon-web-services,aws-lambda,aws-api-gateway,serverless-framework,Node.js,Amazon Web Services,Aws Lambda,Aws Api Gateway,Serverless Framework,我已经创建了一个Lambda授权器方法(基于令牌),带有自定义vpc,并与另一个Lambda集成,用于api网关授权,当授权成功并且到达目标Lambda时,事件中的路径参数和查询参数为null 在serverless.yml文件授权函数中 授权人: 处理程序:authorizerHandler.verifyUser 专有网络:${customvpc} 在serverless.yml文件中为普通lambda 当用户授权时,我将传递并返回对象作为 { "principalId": "yyyyy

我已经创建了一个Lambda授权器方法(基于令牌),带有自定义vpc,并与另一个Lambda集成,用于api网关授权,当授权成功并且到达目标Lambda时,事件中的路径参数和查询参数为null

在serverless.yml文件授权函数中

授权人:
处理程序:authorizerHandler.verifyUser
专有网络:${customvpc}
在serverless.yml文件中为普通lambda

当用户授权时,我将传递并返回对象作为

{
  "principalId": "yyyyyyyy", // The principal user identification associated with the token sent by the client.
  "policyDocument": {
    "Version": "2012-10-17",
    "Statement": [
      {
        "Action": "execute-api:Invoke",
        "Effect": "Allow|Deny",
        "Resource": "arn:aws:execute-api:{regionId}:{accountId}:{apiId}/{stage}/{httpVerb}/[{resource}/[{child-resources}]]"
      }
    ]
  }
}
但是当我尝试在event.pathParameter中使用id时,它返回null,queryStringParameters也是如此。 有人能帮忙吗


提前感谢:-)

我想你需要用大括号
{id}
而不是冒号
:id

 user:
  handler: user.router
  vpc: ${customvpc}
  integration:lambda
  events:
     - http:
         path:api/v1/user/{id}
         cors: true

我想我只是在使用带有类型令牌的自定义授权器时遇到了这个问题。查询字符串信息将仅出现在具有类型请求的授权人上

functions:
  create:
    handler: posts.create
    events:
      - http:
          path: posts/create
          method: post
          authorizer:
            arn: xxx:xxx:Lambda-Name
            resultTtlInSeconds: 0
            identitySource: method.request.header.Authorization, context.identity.sourceIp
            identityValidationExpression: someRegex
            type: request

请注意,将类型从类型令牌更改为类型请求将更改缓存策略密钥的方式


这里还有更多信息:

我只使用了{id},错误地粘贴了邮递员请求,谢谢
functions:
  create:
    handler: posts.create
    events:
      - http:
          path: posts/create
          method: post
          authorizer:
            arn: xxx:xxx:Lambda-Name
            resultTtlInSeconds: 0
            identitySource: method.request.header.Authorization, context.identity.sourceIp
            identityValidationExpression: someRegex
            type: request