説明
OpenAPI 3.0 の OAuth2 の authorizationCode と implicit では、authorizationUrl がログインと同意を行う場所を指定します。
想定される影響
誤ったエンドポイントを指定すると、同意手続きが失敗したり、利用者が信頼できないサイトに誘導されたりする場合があります。
対処方法
components.securitySchemes の対象フローで、authorizationUrl にプロバイダーの公式 HTTPS 認可エンドポイントを指定します。ホストとパスを照合し、# で始まるフラグメントを除いてください。
例
例の authorizationCode を使う場合は、クライアントと認可サーバーで PKCE も設定してください。
変更前
json
{
"openapi": "3.0.0",
"components": {
"securitySchemes": {
"petstore_auth": {
"type": "oauth2",
"flows": {
"authorizationCode": {
"authorizationUrl": "https://api.invalid.company.com#@evil.com/oauth/authorize",
"tokenUrl": "https://api.my.company.com/oauth/token",
"scopes": {
"write:api": "modify apis in your account",
"read:api": "read your apis"
}
}
}
}
}
}
}
変更後
json
{
"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": {
"write:api": "modify apis in your account",
"read:api": "read your apis"
}
}
}
}
}
}
}