Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

ApiGatewayProxyRequestContext.authorizer should be optional #47

Closed
dustbort opened this issue Nov 1, 2021 · 2 comments
Closed

ApiGatewayProxyRequestContext.authorizer should be optional #47

dustbort opened this issue Nov 1, 2021 · 2 comments

Comments

@dustbort
Copy link

dustbort commented Nov 1, 2021

I am using localstack. If no authorization (authorizationType = NONE) is configured for the lambda proxy integration with API gateway, the authorizer field is omitted in the lambda event body.

Currently this is required, causing serde to fail.
https://github.com/LegNeato/aws-lambda-events/blob/master/aws_lambda_events/src/generated/apigw.rs#L121

Error: data did not match any variant of untagged enum LambdaRequest

This is an example lambda event body:

{
  "path": "/",
  "headers": {
    "remote-addr": "172.17.0.1",
    "host": "localhost:4566",
    "connection": "keep-alive",
    "upgrade-insecure-requests": "1",
    "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36",
    "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
    "sec-gpc": "1",
    "sec-fetch-site": "none",
    "sec-fetch-mode": "navigate",
    "sec-fetch-user": "?1",
    "sec-fetch-dest": "document",
    "accept-encoding": "gzip, deflate, br",
    "accept-language": "en-US,en;q=0.9",
    "x-forwarded-for": "172.17.0.1, localhost:4566, 127.0.0.1, localhost:4566",
    "x-localstack-edge": "http://localhost:4566",
    "authorization": "AWS4-HMAC-SHA256 Credential=__internal_call__/20160623/us-east-1/apigateway/aws4_request, SignedHeaders=content-type;host;x-amz-date;x-amz-target, Signature=1234",
    "x-localstack-tgt-api": "apigateway",
    "__apigw_request_region__": "us-east-1"
  },
  "multiValueHeaders": {
    "remote-addr": ["172.17.0.1"],
    "host": ["localhost:4566"],
    "connection": ["keep-alive"],
    "upgrade-insecure-requests": ["1"],
    "user-agent": [
      "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36"
    ],
    "accept": [
      "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"
    ],
    "sec-gpc": ["1"],
    "sec-fetch-site": ["none"],
    "sec-fetch-mode": ["navigate"],
    "sec-fetch-user": ["?1"],
    "sec-fetch-dest": ["document"],
    "accept-encoding": ["gzip, deflate, br"],
    "accept-language": ["en-US,en;q=0.9"],
    "x-forwarded-for": [
      "172.17.0.1, localhost:4566, 127.0.0.1, localhost:4566"
    ],
    "x-localstack-edge": ["http://localhost:4566"],
    "authorization": [
      "AWS4-HMAC-SHA256 Credential=__internal_call__/20160623/us-east-1/apigateway/aws4_request, SignedHeaders=content-type;host;x-amz-date;x-amz-target, Signature=1234"
    ],
    "x-localstack-tgt-api": ["apigateway"],
    "__apigw_request_region__": ["us-east-1"]
  },
  "body": "",
  "isBase64Encoded": false,
  "httpMethod": "GET",
  "queryStringParameters": {},
  "multiValueQueryStringParameters": {},
  "pathParameters": {},
  "resource": "/",
  "requestContext": {
    "path": "/prod/",
    "resourcePath": "/",
    "apiId": "qw9nx3npwz",
    "domainPrefix": "qw9nx3npwz",
    "domainName": "qw9nx3npwz.execute-api.localhost.localstack.cloud",
    "accountId": "000000000000",
    "resourceId": "9htszz4dh3",
    "stage": "prod",
    "identity": {
      "accountId": "000000000000",
      "sourceIp": "127.0.0.1",
      "userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36"
    },
    "httpMethod": "GET",
    "protocol": "HTTP/1.1",
    "requestTime": "2021-11-01T15:45:14.341Z",
    "requestTimeEpoch": 1635781514341
  },
  "stageVariables": {}
}

This issue is similar to other issues about optional fields:
#27
#25

@LegNeato
Copy link
Contributor

Is this correct in the go sdk?

@dustbort
Copy link
Author

This issue has resolved itself after upgrading all packages and redeploying the local stack.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants