AWS SAM Authorizer:获取标头参数的空值

时间:2019-04-22 10:46:49

标签: amazon-web-services aws-lambda aws-api-gateway aws-sam-cli aws-sam

我创建了一个SAM template,其中包括一个包含API Gateway的{​​{1}}。在授权器中,我配置了3个标头参数,即-Lambda AuthorizerauthorizationxXsrfToken。当我使用所有必需的值调用此API时,lambda端仅接收到cookie值,而xXsrfToken即将收到cookieauthorization值。 我在下面共享我的sam模板和AWS控制台快照。

null

使用此模板,我在Amazon控制台上配置了我的Authorizer: enter image description here

当我通过Postman用所有必需的值调用此API时,仅收到AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: > my-api Sample SAM Template for my-api # More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst Globals: Function: Timeout: 20 Resources: TestAuthSAM: Type: AWS::Serverless::Function Properties: CodeUri: target/JWTValidateToken-1.0-SNAPSHOT.jar Handler: com.test.LambdaFunctionHandler::handleRequest Runtime: java8 MyApi: Type: AWS::Serverless::Api Properties: StageName: v1 DefinitionBody: swagger: "2.0" info: version: "2019-04-22T08:30:48Z" title: "TestAuth" host: "d2xas9f38a.execute-api.us-east-2.amazonaws.com" basePath: "/v1" schemes: - "https" paths: /testauth: post: produces: - "application/json" responses: "200": description: "200 response" schema: $ref: "#/definitions/Empty" security: - HelloWorld: [] x-amazon-apigateway-integration: uri: "http://someapi.com/getdata" responses: default: statusCode: "200" passthroughBehavior: "when_no_match" httpMethod: "GET" type: "http" definitions: Empty: type: "object" title: "Empty Schema" Auth: DefaultAuthorizer: MyLambdaRequestAuthorizer Authorizers: MyLambdaRequestAuthorizer: FunctionPayloadType: REQUEST FunctionArn: !GetAtt TestAuthSAM.Arn Identity: Headers: - cookie - xXsrfToken - authorization Outputs: TestAuthSAM: Description: "Custom Cookie Auth Lambda Function ARN" Value: !GetAtt TestAuthSAM.Arn TestAuthSAMIamRole: Description: "Implicit IAM Role created for Custom Cookie Auth function" Value: !GetAtt TestAuthSAM.Arn xXsrfTokenCookieAuthorization的形式出现。 我尝试通过手动配置所有内容来实现相同功能,在这种情况下,它按预期工作。

我的Lambda Authorizer请求类如下:

null

}

0 个答案:

没有答案