Description
With the OAuth2 password flow, the client collects the user’s password. RFC 9700 prohibits this flow.
Potential impact
The client handles a reusable password, and multistep authentication such as MFA is difficult to support.
Remediation
For interactive sign-in, move the client and authorization server to the authorization code flow with PKCE. Set flow to accessCode, supply the provider’s HTTPS endpoints, and match the operation’s required scopes to the scheme.
Examples
GET / continues to require the read:api scope from petstore_auth.
Before
json
{
"swagger": "2.0",
"paths": {
"/": {
"get": {
"security": [
{
"petstore_auth": [
"read:api"
]
}
]
}
}
},
"securityDefinitions": {
"petstore_auth": {
"type": "oauth2",
"flow": "password",
"tokenUrl": "https://api.my.company.com/oauth/token",
"scopes": {
"read:api": "read your apis"
}
}
}
}
After
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"
}
}
}
}