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 Antwort
1
Akzeptierte Antwort

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
beantwortet vor 6 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen