1

我正在尝试在 Cloud Functions 上设置 GraqphQL 服务器,并且我想设置一个 API 网关来处理使用 auth0 和 jwt 的身份验证...。

我从教程中得到了它,问题是它总是需要一个 JWT 令牌,因为我希望一些 GraphQL 查询可以公开使用,并且如果用户登录他们可以获得更多访问权限......

据我了解,您这样做的方式是在安全设置中使用两种身份验证,其中一个是 JWT,一个是空的,但是 API 网关似乎总是想要 JWT 令牌......这是我的开放 API 规范,也许有人有想法吗?

swagger: '2.0'
info:
  title: <redacted>-graphql-api
  description: Basic GraphQL Open APISchema
  version: 1.0.0
schemes:
  - https
produces:
  - application/json
securityDefinitions:
  auth0_jwk:
    authorizationUrl: "<redacted>"
    flow: "implicit"
    type: "oauth2"
    # Replace YOUR-ACCOUNT-NAME with your Auth0 account name.
    x-google-issuer: "<redacted>"
    x-google-jwks_uri: "<redacted>"
    # Optional. Replace YOUR-CLIENT-ID with your client ID
    x-google-audiences: "<redacted>"
paths:
  /:
    post:
      summary: GraphQL endpoint
      operationId: gql
      x-google-backend:
        address: <redacted>  # App URL/endpoint
      responses:
        '200':
          description: A successful response
          schema:
            type: object
      security:
        - {}
        - auth0_jwk: []
    get:
      summary: GraphQL Playground
      operationId: playground
      x-google-backend:
        address: <redacted>  # App URL/endpoint
      responses:
        '200':
          description: A successful response
          schema:
            type: string
4

0 回答 0