【问题标题】:AWS api gateway custom authorizer: access context variable in mapping templateAWS api网关自定义授权者:访问映射模板中的上下文变量
【发布时间】:2017-07-10 19:50:49
【问题描述】:

我已经使用 python 在AWS API Gateway 中实现了一个自定义授权模块。基本上它可能会返回如下内容:

access = {
    "principalId": "yyyyyyyy",
    "policyDocument" : {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Action": "execute-api:Invoke",
                "Resource": [
                    "some-arn/*/GET/organisation"
                ],
                "Effect": "Allow"
            }
        ]
    },
    "context" : {
        "organization_id": "123"
    }
}

在后端站点,我想在 DynamoDb 上执行 GetItem。映射模板如下所示:

{   
    "TableName":"Organisation",
    "Key":{
        "id":{
            "S":"$context.authorizer.organization_id"
        }
    }
}

但是,我收到一个错误,因为 context 变量似乎为空:

Mon Jul 10 19:47:16 UTC 2017 : Endpoint request body after transformations: {   ""
    "TableName":"Organisation",
    "Key":{
        "id":{
            "S":""
        }
    }
}

Mon Jul 10 19:47:16 UTC 2017 : Endpoint response body before transformations: {"__type":"com.amazon.coral.service#SerializationException"}

任何建议,我在这里做错了什么?

【问题讨论】:

    标签: python amazon-web-services aws-api-gateway custom-authentication


    【解决方案1】:

    经过大量测试,我发现问题只有在使用 AWS 控制台进行测试时才会出现。这个问题也包括在here。希望 AWS 能尽快解决这个问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-11-16
      • 2019-07-11
      • 1970-01-01
      • 2018-07-31
      • 1970-01-01
      • 1970-01-01
      • 2018-08-27
      • 2018-03-24
      相关资源
      最近更新 更多