Description
In OpenAPI 2.0 securityDefinitions, type: basic defines a reusable Basic authentication scheme. Reference its name in global or operation-level security to require it.
Potential impact
Basic credentials use Base64 encoding. Over HTTP the username and password can be read and reused.
Remediation
Require HTTPS and server certificate validation for Basic credentials. To migrate to delegated OAuth2 access, configure authorization code with PKCE in the client and authorization server and update the relevant security requirements.
Examples
The example keeps the name petstore_auth while changing its type. Supply the provider’s HTTPS endpoints and require the scopes each operation needs.
Before
json
{
"swagger": "2.0",
"securityDefinitions": {
"petstore_auth": {
"type": "basic",
"description": "Basic authentication"
}
}
}
After
json
{
"swagger": "2.0",
"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"
}
}
}
}