Med*_* V. 8 google-cloud-platform google-api-gateway
我正在尝试设置 Google API Gateway 以使用调用者在标头中发送的 API 密钥。
我的 api 配置 yaml 如下所示:
...
securityDefinitions:
api_key_header:
type: apiKey
name: key
in: header
api_key_query:
type: apiKey
name: key
in: query
paths:
/foo-header:
get:
summary: Test foo endpoint
operationId: testGet-header
x-google-backend:
address: "<backend address>"
protocol: h2
path_translation: APPEND_PATH_TO_ADDRESS
security:
- api_key_header: []
responses:
204:
description: A successful response
/foo-query:
get:
summary: Test foo endpoint
operationId: testGet-header
x-google-backend:
address: "<backend address>"
protocol: h2
path_translation: APPEND_PATH_TO_ADDRESS
security:
- api_key_query: []
responses:
204:
description: A successful response
Run Code Online (Sandbox Code Playgroud)
我预计这两个调用都会失败,/foo-header如果/foo-query未通过标头或查询参数提供有效的 API 密钥,则会出现 401 状态。
但实际上只是/foo-query按照预期行事。
即使请求/foo-header标头中未提供 API 密钥,请求也会传递到后端。
我的配置是否有问题,或者当请求标头中提供 API 密钥时,Google API 网关是否无法正常工作?
Nis*_*an 10
什么时候in是header,就name应该是x-api-key。
https://cloud.google.com/endpoints/docs/openapi/openapi-limitations#api_key_definition_limitations
| 归档时间: |
|
| 查看次数: |
5560 次 |
| 最近记录: |