Skip to content

APIGatewayV2Request doesn't support AWS_IAM authorizers #40

Closed
@sebsto

Description

@sebsto

Expected behavior

APIGatwewayV2Request should support iam authorizers.

requestDecoding(Swift.DecodingError.keyNotFound(CodingKeys(stringValue: "jwt", intValue: nil), Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "requestContext", intValue: nil), CodingKeys(stringValue: "authorizer", intValue: nil)], debugDescription: "No value associated with key CodingKeys(stringValue: \"jwt\", intValue: nil) (\"jwt\").", underlyingError: nil)))

Actual behavior

Fail to decode to JSON

Steps to reproduce

  1. Create a Lambda Function + hook it up to an API Gateway with IAM authorization enabled.

Here is a SAM snippet

Resources:
  # Lambda function
  MyLambdaFunction:
    Type: AWS::Serverless::Function
    Properties:
      Events:
        # pass through all HTTP verbs and paths
        Api:
          Type: HttpApi
          Properties:
            Auth:
              Authorizer: AWS_IAM            
    Metadata:
      BuildMethod: makefile

If possible, minimal yet complete reproducer code (or URL to code)

Here is the payload received that fails to decode :

{
    "version": "2.0",
    "routeKey": "$default",
    "rawPath": "/liveness",
    "rawQueryString": "",
    "headers": {
        "accept": "*/*",
        "authorization": "AWS4-HMAC-SHA256 Credential=ASIA-redacted/us-east-1/execute-api/aws4_request, SignedHeaders=host;x-amz-date;x-amz-security-token, Signature=289b5fcef3d1156f019cc1140cb5565cc052880a5a0d5586c753e3e3c75556f9",
        "content-length": "0",
        "host": "74bxj8iqjc.execute-api.us-east-1.amazonaws.com",
        "user-agent": "curl/8.4.0",
        "x-amz-date": "20231214T203121Z",
        "x-amz-security-token": "IQoJb3JpZ2luX2VjEO3//////////-redacted",
        "x-amzn-trace-id": "Root=1-657b6619-3222de40051925dd66e1fd72",
        "x-forwarded-for": "191.95.150.52",
        "x-forwarded-port": "443",
        "x-forwarded-proto": "https"
    },
    "requestContext": {
        "accountId": "012345678912",
        "apiId": "74bxj8iqjc",
        "authorizer": {
            "iam": {
                "accessKey": "ASIA-redacted",
                "accountId": "486652066693",
                "callerId": "AIDA-redacted",
                "cognitoIdentity": null,
                "principalOrgId": "aws:PrincipalOrgID",
                "userArn": "arn:aws:iam::012345678912:user/sst",
                "userId": "AIDA-redacted"
            }
        },
        "domainName": "74bxj8iqjc.execute-api.us-east-1.amazonaws.com",
        "domainPrefix": "74bxj8iqjc",
        "http": {
            "method": "GET",
            "path": "/liveness",
            "protocol": "HTTP/1.1",
            "sourceIp": "191.95.150.52",
            "userAgent": "curl/8.4.0"
        },
        "requestId": "P8zkDiQ8oAMEJsQ=",
        "routeKey": "$default",
        "stage": "$default",
        "time": "14/Dec/2023:20:31:21 +0000",
        "timeEpoch": 1702585881671
    },
    "isBase64Encoded": false
}

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions