In mongodb/mongo-php-driver#966, a user attempted to connect to the database with the following connection string:
mongodb://@localhost:27017
I believe mongoc_uri_parse_before_slash() parsed this string and yielded an empty string for the username and a null password. As a result, mongoc_cluster_init() later decided that authentication was required due to a non-null username (no auth source was specified). This led to a very cryptic "Authentication failed." error message from the server. I assume the "@" was a typo, as the user originally reported that they were not using authentication.
I'm not sure if there is any valid use case where an empty username would be accepted by the server. If not, perhaps we can consider adding some validation around this to raise a client-side error during URI parsing – or at least not decide to require auth if username is an empty string.
- is depended on by
-
PHPC-1346 Do not allow empty string for username
- Closed
- links to