Skip to content

Commit f72d196

Browse files
committed
Merge pull request #1107
2 parents 922f6a6 + 6ae4d9d commit f72d196

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

config.m4

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,8 @@ if test "$PHP_MONGODB" != "no"; then
390390

391391
dnl If compiling without libmongocrypt, use kms_message sources bundled with libmongoc.
392392
dnl If compiling with libmongocrypt, kms_message bundled with libmongocrypt is used as it is most likely newer.
393-
if test "$PHP_MONGODB_CLIENT_SIDE_ENCRYPTION" != "yes" && "$PHP_MONGODB_SSL" != "no"; then
393+
if test "$PHP_MONGODB_CLIENT_SIDE_ENCRYPTION" != "yes" && test "$PHP_MONGODB_SSL" != "no"; then
394+
AC_SUBST(MONGOC_ENABLE_MONGODB_AWS_AUTH, 1)
394395
PHP_MONGODB_ADD_SOURCES([src/libmongoc/src/kms-message/src/], $PHP_MONGODB_KMS_MESSAGE_SOURCES, $PHP_MONGODB_BUNDLED_CFLAGS)
395396
PHP_MONGODB_ADD_INCLUDE([src/libmongoc/src/kms-message/src/])
396397
PHP_MONGODB_ADD_BUILD_DIR([src/libmongoc/src/kms-message/src/])
@@ -416,6 +417,8 @@ if test "$PHP_MONGODB" != "no"; then
416417
fi
417418

418419
if test "$PHP_MONGODB_CLIENT_SIDE_ENCRYPTION" = "yes"; then
420+
dnl Since libmongocrypt adds kms-message, we can enable AWS auth in this case
421+
AC_SUBST(MONGOC_ENABLE_MONGODB_AWS_AUTH, 1)
419422
AC_SUBST(MONGOCRYPT_ENABLE_TRACE, 1)
420423

421424
dnl Generated with: find src/libmongocrypt/src -maxdepth 1 -name '*.c' -print0 | cut -sz -d / -f 4- | sort -dz | tr '\000' ' '

config.w32

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ if (PHP_MONGODB != "no") {
213213
mongoc_opts.MONGOC_ENABLE_CRYPTO_LIBCRYPTO = 1;
214214
mongoc_opts.MONGOC_ENABLE_SSL = 1;
215215
mongoc_opts.MONGOC_ENABLE_CRYPTO = 1;
216+
mongoc_opts.MONGOC_ENABLE_MONGODB_AWS_AUTH = 1;
216217

217218
ADD_FLAG("CFLAGS_MONGODB", "/D KMS_MSG_STATIC=1 /D KMS_MESSAGE_ENABLE_CRYPTO=1 /D KMS_MESSAGE_ENABLE_CRYPTO_LIBCRYPTO=1");
218219
} else {

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)