説明
全体の security 配列に {} を入れると、ほかの認証方式があっても匿名アクセスを選べます。
想定される影響
この設定を継承する操作では、認証が任意であるとクライアントに伝わります。
対処方法
認証を必須にするには {} を配列から削除し、サーバーが要求する方式を参照します。security 自体は配列なので、security: {} という形式は無効です。
例
変更後は exampleSecurity が定義する X-API-Key ヘッダーが必要です。
変更前
json
{
"openapi": "3.0.0",
"paths": {
"/": {
"get": {
"responses": {
"200": {
"description": "ok"
}
}
}
}
},
"security": [
{}
],
"info": {
"title": "Simple API overview",
"version": "1.0.0"
},
"components": {
"securitySchemes": {
"exampleSecurity": {
"type": "apiKey",
"in": "header",
"name": "X-API-Key"
}
}
}
}
変更後
json
{
"openapi": "3.0.0",
"paths": {
"/": {
"get": {
"responses": {
"200": {
"description": "ok"
}
}
}
}
},
"security": [
{
"exampleSecurity": []
}
],
"info": {
"title": "Simple API overview",
"version": "1.0.0"
},
"components": {
"securitySchemes": {
"exampleSecurity": {
"type": "apiKey",
"in": "header",
"name": "X-API-Key"
}
}
}
}