将KeyCloak的OAuth2与Connexion结合(使用OpenAPI v3)

时间:2020-02-14 11:19:44

标签: oauth-2.0 openid-connect keycloak openapi connexion

我对OAuth非常了解,并且正在研究Flask应用程序,因此决定使用OAuth2.0是一个有趣的候选人。

我的特定软件堆栈在后端​​是Connexion,在OAuth提供者/用户管理中是KeyCloak。但是我假设我正在破坏最基本的OAuth2 <-> OpenAPI定义。

到目前为止,我的OpenAPI定义如下:

openapi: "3.0.0"
info:
  # ...

components:
  securitySchemes:
    oAuthSample:
      type: oauth2
      description: (...)
      # The following is connexion specific and I am not sure what it exactly is
      x-tokenInfoUrl: http://localhost:5000/tokeninfo
      flows:
        authorizationCode:
          authorizationUrl: http://localhost:8080/auth/realms/master/protocol/openid-connect/auth
          tokenUrl: http://localhost:8080/auth/realms/master/protocol/openid-connect/token          
          scopes:
            read_pets: read your pets

paths:
  /pets:
    get:
      summary: List all pets
      operationId: api.list_pets
      tags:
        - pets
      parameters:
        - # ...
      security: 
        - oAuthSample: 
          - read_pets

我的第一个问题是,执行GET到/ api / v1 / pets时,我收到401错误,但是我期待一些重定向-这就是OAuth应该如何工作的,对吗?

x-tokenInfoUrl(或者与此有关的x-tokenInfoFunc)是模糊的,我读过the documentation,但是它太抽象了,我不知道应该检查什么。不是通过其他授权URL建立的吗?

0 个答案:

没有答案