Skip to content

CDRIVER-4489 refactor URI auth finalization by authentication mechanism #1896

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 62 commits into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
f4d19f6
Document the implementation of MongoCredential from Authentication spec
eramongodb Mar 5, 2025
f0e695c
Fix captured log assertions for test_mongoc_uri_duplicates
eramongodb Mar 5, 2025
22b12b7
CDRIVER-4489 refactor URI auth finalization by authentication mechanism
eramongodb Mar 5, 2025
2ba6bca
CDRIVER-4128 add warning for unsupported CANONICALIZE_HOST_NAME values
eramongodb Mar 5, 2025
53c14aa
Modernize test code for URI and connection strings
eramongodb Mar 5, 2025
22200f6
Remove obsolete(?) comment concerning GSSAPISERVICENAME overwrites
eramongodb Mar 5, 2025
ed04926
Extend authentication mechanism test coverage
eramongodb Mar 5, 2025
006ca81
Update wording for NEWS entries
eramongodb Mar 5, 2025
6c844c5
Update spec comment format for consistency
eramongodb Mar 5, 2025
351e683
Remove superceded auth mechanism test code
eramongodb Mar 6, 2025
882cef9
Consistently order log assertions before error assertions
eramongodb Mar 6, 2025
4b72113
Restore authSource test coverage for default authentication mechanism
eramongodb Mar 6, 2025
92c9e82
Merge remote-tracking branch 'upstream/master' into HEAD
eramongodb Mar 7, 2025
3fe0a17
CDRIVER-5773 further remove support and testing of MONGODB-CR
eramongodb Mar 7, 2025
af19541
Merge remote-tracking branch 'upstream/master' into HEAD
eramongodb Mar 7, 2025
dcd9229
Restore case-insensitivity of authMechanism values
eramongodb Mar 7, 2025
b5caa84
Fix missing destruction of bson_t
eramongodb Mar 7, 2025
6017e13
Add reference to Authentication spec justifying case-insensitivity
eramongodb Mar 7, 2025
e492d5d
Fix overspecific comment left over from function extraction
eramongodb Mar 7, 2025
4c61b62
Fix case-insensitivity of SERVICE_NAME comparison
eramongodb Mar 7, 2025
0bf433f
Handle "auth", "options", and "credential" individually
eramongodb Mar 7, 2025
e6454b3
CDRIVER-5812 remove workaround for incorrect MONGODB-AWS authSource
eramongodb Mar 7, 2025
884199e
CDRIVER-5811 remove test skip for MONGODB-AWS username and password v…
eramongodb Mar 7, 2025
11eae78
Enforce correct username and password provision requirements for MONG…
eramongodb Mar 7, 2025
5381417
Add back-reference to `!mechanism && !username` for default auth method
eramongodb Mar 7, 2025
adf5154
Convert internal BSON append failures into assertions
eramongodb Mar 7, 2025
a703767
Promote invalid or unsupported authMechanism to client error
eramongodb Mar 7, 2025
50efb70
CDRIVER-4128 promote invalid or unsupported CANONICALIZE_HOST_NAME va…
eramongodb Mar 7, 2025
743bab2
Copy wording for CDRIVER-1959 workaround to test case
eramongodb Mar 7, 2025
dab9c74
Include "SERVICE_NAME" in GSSAPI match assertions
eramongodb Mar 7, 2025
bf5a326
Add authMechanismProperties case-insensitivity coverage
eramongodb Mar 7, 2025
cb464d0
Fix conditions in compatibility comment
eramongodb Mar 7, 2025
2b43f16
Add missing designated initializer
eramongodb Mar 7, 2025
abacd85
Address -Wunused-variable warnings
eramongodb Mar 7, 2025
426cae7
CDRIVER-3517 promote empty authSource to client error
eramongodb Mar 7, 2025
5747888
Update AWS tests to match behavior changes
eramongodb Mar 7, 2025
1ece2f3
Merge remote-tracking branch 'upstream/master' into HEAD
eramongodb Mar 7, 2025
ae97cf0
Revert "Update AWS tests to match behavior changes"
eramongodb Mar 7, 2025
6bb739e
Bypass URI auth finalization for mongoc-cluster-aws.c test coverage
eramongodb Mar 7, 2025
dab837d
Use mongoc_uri_new_with_error for ASSERT_OR_PRINT
eramongodb Mar 7, 2025
be68b57
Modernize test code for test-mongoc-aws.c
eramongodb Mar 7, 2025
90ca388
Revert to returning a client error on internal BSON failures
eramongodb Mar 11, 2025
47780a0
Merge remote-tracking branch 'upstream/master' into HEAD
eramongodb Mar 12, 2025
f9f5289
Include expected type in mech prop error message
eramongodb Mar 12, 2025
01db223
Fix comment justifying auth mech property errors
eramongodb Mar 12, 2025
2452be7
Fix typo: saslSupportedMechs
eramongodb Mar 12, 2025
76bf1fe
Use CMPUINT16 for port assertions
eramongodb Mar 12, 2025
d5151e7
Avoid self-explanatory messages in assertions
eramongodb Mar 12, 2025
6b42b25
Remove stray call to clear_captured_logs
eramongodb Mar 12, 2025
ab9009a
Use bsonVisitEach to exhaust all expected credentials fields
eramongodb Mar 12, 2025
5f1d121
Add missing ASSERT_OR_PRINT
eramongodb Mar 12, 2025
e150896
Update error message for username xor password
eramongodb Mar 12, 2025
5b07d1a
Avoid leaky reuse of bson_error_t across assertions
eramongodb Mar 12, 2025
1975dcd
Add missing negative assertion of uri
eramongodb Mar 12, 2025
1005911
Tweak error message for empty authSource
eramongodb Mar 12, 2025
5b390a2
Remove stray optional param assertion
eramongodb Mar 12, 2025
c655789
List supported authMechanism values in error message
eramongodb Mar 12, 2025
7175b61
Also update second reference to Connection String spec error handling…
eramongodb Mar 13, 2025
7935628
CDRIVER-5776 avoid assertions for null fields
eramongodb Mar 14, 2025
60ac146
Merge remote-tracking branch 'upstream/master' into cdriver-4489-pre
eramongodb Mar 17, 2025
9a8bd82
Fix potential leak of temporary prop BSON object + null bsonBuildErro…
eramongodb Mar 17, 2025
14530a8
Assert no duplication of spec test fields
eramongodb Mar 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,26 @@ Instead, the names must be prefixed with the parent directory: `mongoc/mongoc.h`
```


Changes:

* URI authentication credentials validation (only applicable during creation of a new `mongoc_uri_t` object from a connection string):
* `authMechanism` is now validated and returns a client error for invalid or unsupported values.
* `authSource` is now validated and returns a client error for invalid or unsupported values for the specified `authMechanism`.
* `authSource` is now correctly defaulted to `"$external"` for MONGODB-AWS (instead of the database name or `"admin"`).
* The requirement that a password is provided is now enforced when the authentication mechanism is specified for:
* PLAIN
* SCRAM-SHA-1
* SCRAM-SHA-256
* The requirement that neither or both a username and password is provided (optionally with a `AWS_SESSION_TOKEN`) is now enforced for MONGODB-AWS.
* `authMechanismProperties` is now prohibited (instead of ignored) when the authentication mechanism is specified for:
* PLAIN
* SCRAM-SHA-1
* SCRAM-SHA-256
* MONGODB-X509
* `authMechanismProperties` is now validated and returns a client error for invalid or unsupported fields when the authentication mechanism is specified for:
* GSSAPI: supported fields are SERVICE_NAME, CANONICALIZE_HOST_NAME, SERVICE_REALM, and SERVICE_HOST.
* MONGODB-AWS: supported fields are AWS_SESSION_TOKEN.

libmongoc 1.30.2
================

Expand Down
13 changes: 11 additions & 2 deletions src/libmongoc/src/mongoc/mongoc-sasl.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,18 @@ _mongoc_sasl_set_properties (mongoc_sasl_t *sasl, const mongoc_uri_t *uri)
canonicalize = bson_iter_bool (&iter);
}

/* newer "authMechanismProperties" URI syntax takes precedence */
if (bson_iter_init_find_case (&iter, &properties, "CANONICALIZE_HOST_NAME") && BSON_ITER_HOLDS_UTF8 (&iter)) {
/* newer "authMechanismProperties" URI syntax takes precedence */
canonicalize = !strcasecmp (bson_iter_utf8 (&iter, NULL), "true");
const char *const value = bson_iter_utf8 (&iter, NULL);

const bool is_true = strcasecmp (value, "true") == 0;

// CDRIVER-4128: only legacy boolean values are currently supported.
if (!is_true && strcasecmp (value, "false") != 0) {
MONGOC_WARNING ("Unsupported value for \"CANONICALIZE_HOST_NAME\": \"%s\"", value);
} else {
canonicalize = is_true;
}
}

sasl->canonicalize_host_name = canonicalize;
Expand Down
Loading