簡體   English   中英

AWS api網關定制授權者:訪問映射模板中的上下文變量

[英]AWS api gateway custom authorizer: access context variable in mapping template

我已經使用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"}

任何建議,我在這里做錯了什么?

經過大量測試,我發現問題僅在使用AWS控制台進行測試時才出現。 此問題也在此處討論 希望AWS會盡快解決此問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM