我对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建立的吗?