1

我使用Cloud Endpoint的版本控制功能(即gcloud service-management deploy openapi_v1.yaml openapi_v2.yaml)将2个版本的openapi.yaml文件部署到了Google Cloud Endpoint。 yaml文件的每个版本都包含不同于另一版本的版本号和基本路径,一个使用api-key认证的端点以及api-key认证标签的定义。在部署到Endpoint后,配置将显示yaml文件,但使用此配置将api部署到GAE只会为新版本启用api-key身份验证。如何在将多个版本部署到Google Clould Endpoint中的相同配置时为所有版本启用api-key auth

有谁知道这是一个已知的错误,还是有其他事情我需要做以启用所有版本的身份验证?

.yaml文件如下所示。我用来测试上的两个版本,除了版本和bathpath相同:

swagger: "2.0" 
info: 
    description: "This API is used to connect 3rd-party ids to a common user identity" 
    version: "0.0.1" 
    title: "****" 
host: "uie-dot-user-id-exchange.appspot.com" 
basePath: "/v0" 

... 

- "https" 
x-google-allow: all 

paths: 

    ... 

    /ids/search: 
    get: 
     operationId: "id_search" 
     produces: 
     - "application/json" 
     security: 
     - api_key: [] 
     tags: 
     - "Ids" 
     summary: "Privileged endpoint. Provide any id (3rd party or otherwise) and get a hash of all ids associated with it." 
     parameters: 
     - in: "query" 
     name: "id_type" 
     description: "Type of id to search" 
     required: true 
     type: string 
     - in: "query" 
     name: "id_value" 
     description: "Value of id to search" 
     required: true 
     type: string 
     responses: 
     200: 
      description: "AssociatedIdsHash" 
      schema: 
      $ref: '#/definitions/AssociatedIdsHash' 
     400: 
      description: "Bad request. Requires both id_type and id_value query parameters." 
     401: 
      description: "Unauthorized. Please provide a valid api-key in the \"api-key\" header." 
     404: 
      description: "Not found - no entry found for key provided" 

... 

################ SECURITY DEFINITIONS ################ 
securityDefinitions: 
    # This section configures basic authentication with an API key. 
    api_key: 
    type: "apiKey" 
    name: "key" 
    in: "query" 
+0

你可以发布你的yaml文件吗? –

回答

0

我可以复制这个问题,这似乎是一个错误。

什么工作是在全局级别上为这两个版本添加API密钥限制,而不是在每个路径级别。也许这个解决方法就足以满足你的用例。

... 
security: 
- api_key: [] 
path: 
... 
+0

谢谢您的确认。有没有时间表,这将被固定?对于该项目,我们确实需要在每个路径级别上启用api_key auth –

+0

该修复没有时间表,但是一个错误已被记录并正在被跟踪。 –

相关问题