Description
For an authenticated OpenAPI 3.0 API, define the scheme in components.securitySchemes and reference it by name in global or operation-level security. An intentionally public API can omit it.
Potential impact
A client may omit a required header or token and have its request rejected.
Remediation
Enforce the same requirement on the server or gateway. Check that a protected operation accepts valid credentials and rejects a request without them.
Examples
The example defines exampleSecurity as HTTP Bearer and applies the global requirement to GET /. The server still needs to validate the bearer token.
Before
json
{
"openapi": "3.0.0",
"info": {
"title": "Simple API overview",
"version": "1.0.0"
},
"paths": {
"/": {
"get": {
"responses": {
"200": {
"description": "200 response"
}
}
}
}
}
}
After
json
{
"openapi": "3.0.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0"
},
"paths": {
"/": {
"get": {
"responses": {
"200": {
"description": "200 response"
}
}
}
}
},
"security": [
{
"exampleSecurity": []
}
],
"components": {
"securitySchemes": {
"exampleSecurity": {
"type": "http",
"scheme": "bearer"
}
}
}
}