Rest api gateway, custom api key header name

0

I created the objects needed to enable 'API Key Required'=true on the API gateway. But I am not able to change the default x-api-key header name. My understanding is that since the api gateway supports openapi 3.0, so in the openapi file, included into Gateway config, I added the sections:

components
    securitySchemes:
        api_key:
        type: "apiKey"
        name: "custom-header-name"
        in: "header"
security:
  - api_key: []

Unfortunately, after deploying on AWS via cloud formation, the settings are overwritten and the "x-api-key" header is still expected instead of "custom-header-name"

1 回答
1
已接受的回答

As stated in the documentation "header sourced API Keys" must use the "x-api-key" header.

https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-api-key-source.html#:~:text=key%20as%20the-,X%2DAPI%2DKey,-header%20of%20each

If you want to call the API key-required methods without explicitly supplying any API key. You can use the authorizes-sourced API Keys:

https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-api-key-source.html#:~:text=authorizer%2Dsourced%20API%20keys

AWS
vtjean
已回答 7 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则