説明
操作の security が implicit フローを参照している場合、クライアントはリダイレクトの応答でアクセストークンを受け取ります。
想定される影響
トークンが漏れると、その権限を第三者に使われるおそれがあります。誤ったトークンを受け入れると、別のアカウントでリクエストが処理される場合もあります。
対処方法
クライアントと認可サーバーを PKCE を使う認可コードフローに移行します。securityDefinitions のフローを accessCode に変更し、プロバイダーの HTTPS エンドポイントを指定してください。操作には必要なスコープだけを要求します。
例
例の GET / は引き続き petstore_auth を参照し、read:api だけを要求します。
変更前
json
{
"swagger": "2.0",
"paths": {
"/": {
"get": {
"security": [
{
"petstore_auth": []
}
]
}
}
},
"securityDefinitions": {
"petstore_auth": {
"type": "oauth2",
"flow": "implicit",
"authorizationUrl": "https://api.my.company.com/oauth/authorize",
"scopes": {
"read:api": "read your apis"
}
}
}
}
変更後
json
{
"swagger": "2.0",
"paths": {
"/": {
"get": {
"security": [
{
"petstore_auth": [
"read:api"
]
}
]
}
}
},
"securityDefinitions": {
"petstore_auth": {
"type": "oauth2",
"flow": "accessCode",
"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"
}
}
}
}