Skip to content

Commit 6ae4d9d

Browse files
committed
PHPC-1483: Add support for MONGODB-AWS auth mechanism
1 parent b6fed72 commit 6ae4d9d

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

php_phongo.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,8 +1374,9 @@ static bool php_phongo_uri_finalize_auth(mongoc_uri_t* uri) /* {{{ */
13741374
}
13751375
}
13761376

1377-
/* MONGODB-X509 is the only mechanism that doesn't require username */
1378-
if (strcasecmp(mongoc_uri_get_auth_mechanism(uri), "MONGODB-X509")) {
1377+
/* Mechanisms other than MONGODB-X509 and MONGODB-AWS require a username */
1378+
if (strcasecmp(mongoc_uri_get_auth_mechanism(uri), "MONGODB-X509") &&
1379+
strcasecmp(mongoc_uri_get_auth_mechanism(uri), "MONGODB-AWS")) {
13791380
if (!mongoc_uri_get_username(uri) ||
13801381
!strcmp(mongoc_uri_get_username(uri), "")) {
13811382
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT, "Failed to parse URI options: '%s' authentication mechanism requires username.", mongoc_uri_get_auth_mechanism(uri));

tests/manager/manager-ctor-auth_mechanism-001.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ $tests = [
77
['mongodb://[email protected]/?authMechanism=MONGODB-X509', []],
88
['mongodb://127.0.0.1/?authMechanism=MONGODB-X509', []],
99
['mongodb://[email protected]/?authMechanism=GSSAPI', []],
10+
['mongodb://127.0.0.1/?authMechanism=MONGODB-AWS', []],
1011
[null, ['authMechanism' => 'MONGODB-X509', 'username' => 'username']],
1112
[null, ['authMechanism' => 'MONGODB-X509']],
1213
[null, ['authMechanism' => 'GSSAPI', 'username' => 'username']],
14+
[null, ['authMechanism' => 'MONGODB-AWS']],
1315
];
1416

1517
foreach ($tests as $test) {

0 commit comments

Comments
 (0)