Description
In OpenAPI 2.0 securityDefinitions, flow: password describes a client that collects users’ passwords. RFC 9700 prohibits this grant.
Potential impact
Users entrust their passwords to the client, and browser-based sign-in or multistep authentication is difficult to support.
Remediation
For delegated user access, configure the authorization code flow with PKCE in the client and authorization server. Set flow: accessCode, enter the provider’s HTTPS authorizationUrl and tokenUrl, and define the supported scopes.
Examples
The excerpt defines petstore_auth. Reference it in global or operation-level security to require it.
Before
json
{
"swagger": "2.0",
"securityDefinitions": {
"petstore_auth": {
"type": "oauth2",
"flow": "password",
"tokenUrl": "https://api.my.company.com/oauth/token"
}
}
}
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"
}
}
}
}