Skip to content

Commit b1ff5d6

Browse files
authored
CDRIVER-4489 promote empty username to client error (#1939)
1 parent 1ca2bfa commit b1ff5d6

File tree

3 files changed

+152
-152
lines changed

3 files changed

+152
-152
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Unreleased (2.0.0)
99
* `bson_oid_init_sequence` is removed. Use `bson_oid_init` instead.
1010
* `mongoc_server_description_host` changes the return type from `mongoc_host_list_t *` to `const mongoc_host_list_t *`.
1111
* URI authentication credentials validation (only applicable during creation of a new `mongoc_uri_t` object from a connection string):
12+
* The requirement that a username is non-empty when specified is now enforced regardless of authentication mechanism.
1213
* `authMechanism` is now validated and returns a client error for invalid or unsupported values.
1314
* `authSource` is now validated and returns a client error for invalid or unsupported values for the specified `authMechanism`.
1415
* `authSource` is now correctly defaulted to `"$external"` for MONGODB-AWS (instead of the database name or `"admin"`).

src/libmongoc/src/mongoc/mongoc-uri.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,6 +1315,10 @@ _finalize_auth_username (const char *username,
13151315

13161316
case _mongoc_uri_finalize_allowed:
13171317
default:
1318+
if (username && strlen (username) == 0u) {
1319+
MONGOC_URI_ERROR (error, "'%s' authentication mechanism requires a non-empty username", mechanism);
1320+
return false;
1321+
}
13181322
break;
13191323
}
13201324

0 commit comments

Comments
 (0)