説明
OpenAPI 3.0 の authorizationCode などのフローは、tokenUrl をトークンの要求先に使います。implicit フローではトークンエンドポイントを使いません。
想定される影響
宛先が誤っていると、トークンの発行に失敗したり、認証情報が意図しないサーバーに渡ったりするおそれがあります。
対処方法
components.securitySchemes の対象フローで、tokenUrl にプロバイダーの公式 HTTPS トークンエンドポイントを設定します。# で始まるフラグメントは含めず、クライアントの接続先と証明書の検証を確認してください。
例
この例は authorizationCode のトークンエンドポイントを修正します。ログイン先は引き続き authorizationUrl に指定します。
変更前
yaml
openapi: 3.0.0
components:
securitySchemes:
petstore_auth:
type: oauth2
flows:
authorizationCode:
authorizationUrl: https://api.my.company.com/oauth/authorize
tokenUrl: http://example.com#@evil.com/
scopes:
read:api: read your apis
変更後
yaml
openapi: 3.0.0
components:
securitySchemes:
petstore_auth:
type: oauth2
flows:
authorizationCode:
authorizationUrl: https://api.my.company.com/oauth/authorize
tokenUrl: https://api.my.company.com/oauth/token
scopes:
read:api: read your apis