【问题标题】:Multiple Authentication "OR" not working in Google Cloud Endpoints OpenAPI多重身份验证“OR”在 Google Cloud Endpoints OpenAPI 中不起作用
【发布时间】:2023-03-14 16:00:01
【问题描述】:

在 Google Cloud Endpoints 中,我无法在“或”场景中进行身份验证,例如,我想允许通过 api_key“或”oauth 访问路径。请参阅https://swagger.io/docs/specification/2-0/authentication/ 了解更多信息。

有效(API 密钥的单一定义)

/api/query:
  get:
  operationId: queryget
  responses:
    '200':
      description: query success
  security:
     - api_key: []

有效(oauth 的单一定义)

/api/query:
  get:
  operationId: queryget
  responses:
    '200':
      description: query success
  security:
     - oauth: []

有效(“AND”定义,其中两者都必须包含在身份验证中)

/api/query:
  get:
  operationId: queryget
  responses:
    '200':
      description: query success
  security:
     - oauth: []
       api_key: []

不起作用(“或”定义)

/api/query:
  get:
  operationId: queryget
  responses:
    '200':
      description: query success
  security:
     - oauth: []
     - api_key: []

更具体地说,将我的 api 部署到 Google Cloud Endpoints 时,我收到以下警告

Operation 'get' in path '/api/query': Operation does not require an API key; callers may invoke the method without specifying an associated API-consuming project. 

并且,当尝试使用 API 密钥调用 api 时,我收到以下错误,好像它需要 OAUTH JWT 令牌(可能是因为它是该路由列表中的第一个安全定义)

{ "code": 16, "message": "JWT validation failed: Missing or invalid credentials", "details": [  {   "@type": "type.googleapis.com/google.rpc.DebugInfo",   "stackEntries": [],   "detail": "auth"  } ]}' 

【问题讨论】:

  • 您需要更准确地了解“不起作用”的含义。有什么症状?您提到的错误只是一个警告。
  • 我更新了描述以包含错误消息。如果您想了解更多信息,请告诉我。

标签: swagger google-cloud-endpoints openapi


【解决方案1】:

很遗憾,此功能不受支持。您只能使用 AND。这现在记录在 Unsupported OpenAPI Features 中。

【讨论】:

  • 将是一个很好的功能请求。感谢您的快速回复。
猜你喜欢
  • 1970-01-01
  • 2014-10-11
  • 1970-01-01
  • 2018-12-29
  • 1970-01-01
  • 2016-02-03
  • 1970-01-01
  • 2017-07-06
  • 1970-01-01
相关资源
最近更新 更多