Skip to content

APIGatewayV2Request doesn't support AWS_IAM authorizers #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sebsto opened this issue Dec 14, 2023 · 1 comment
Closed

APIGatewayV2Request doesn't support AWS_IAM authorizers #40

sebsto opened this issue Dec 14, 2023 · 1 comment
Assignees

Comments

@sebsto
Copy link
Contributor

sebsto commented Dec 14, 2023

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
}
@sebsto
Copy link
Contributor Author

sebsto commented Dec 16, 2023

fixed by #41

@sebsto sebsto closed this as completed Dec 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants