Skip to content

Commit b1e0274

Browse files
DRIVERS-2769 Clarify not validating saslSupportedMechs (#1565)
1 parent fe86082 commit b1e0274

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

source/auth/auth.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@ If the handshake response includes a `saslSupportedMechs` field, then drivers MU
174174
select a default mechanism as described later. If the command succeeds and the response does not include a
175175
`saslSupportedMechs` field, then drivers MUST use the legacy default mechanism rules for servers older than 4.0.
176176

177+
Drivers MUST NOT validate the contents of the `saslSupportedMechs` attribute of the initial handshake reply. Drivers
178+
MUST NOT raise an error if the `saslSupportedMechs` attribute of the reply includes an unknown mechanism.
179+
177180
### Single-credential drivers
178181

179182
When the authentication mechanism is not specified, drivers that allow only a single credential per client MUST perform
@@ -2050,6 +2053,8 @@ to EC2 instance metadata in ECS, for security reasons, Amazon states it's best p
20502053

20512054
## Changelog
20522055

2056+
- 2024-04-22: Clarify that driver should not validate `saslSupportedMechs` content.
2057+
20532058
- 2024-04-03: Added GCP built-in OIDC provider integration.
20542059

20552060
- 2024-03-29: Updated OIDC test setup and descriptions.

source/auth/auth.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,11 @@ to select a default mechanism as described later. If the command succeeds and
217217
the response does not include a ``saslSupportedMechs`` field, then drivers MUST
218218
use the legacy default mechanism rules for servers older than 4.0.
219219

220+
Drivers MUST NOT validate the contents of the ``saslSupportedMechs``
221+
attribute of the initial handshake reply. Drivers MUST NOT raise an error if
222+
the ``saslSupportedMechs`` attribute of the reply includes an unknown mechanism.
223+
224+
220225
Single-credential drivers
221226
`````````````````````````
222227

@@ -1661,6 +1666,7 @@ Q: Should drivers support accessing Amazon EC2 instance metadata in Amazon ECS?
16611666
Changelog
16621667
=========
16631668

1669+
:2024-04-22: Clarify that driver should not validate ``saslSupportedMechs`` content.
16641670
:2023-04-28: Added MONGODB-OIDC auth mechanism
16651671
:2022-11-02: Require environment variables to be read dynamically.
16661672
:2022-10-28: Recommend the use of AWS SDKs where available.

source/mongodb-handshake/handshake.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,10 @@ The ``speculativeAuthenticate`` reply has the same fields, except for the ``ok``
424424
as seen in the conversation sections for MONGODB-X509, SCRAM-SHA-1 and SCRAM-SHA-256
425425
in the `Driver Authentication spec <../auth/auth.md#supported-authentication-methods>`_.
426426

427+
Drivers MUST NOT validate the contents of the ``saslSupportedMechs`` attribute
428+
of the initial handshake reply. Drivers MUST NOT raise an error if the
429+
``saslSupportedMechs`` attribute of the reply includes an unknown mechanism.
430+
427431
If an authentication mechanism is not provided either via connection string or code, but
428432
a credential is provided, drivers MUST use the SCRAM-SHA-256 mechanism for speculative
429433
authentication and drivers MUST send ``saslSupportedMechs``.
@@ -675,3 +679,4 @@ Changelog
675679
:2023-04-03: Simplify truncation for metadata
676680
:2023-05-04: ``AWS_EXECUTION_ENV`` must start with ``"AWS_Lambda_"``
677681
:2023-08-24: Added container awareness
682+
:2024-04-22: Clarify that driver should not validate ``saslSupportedMechs`` content.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# MongoDB Handshake Tests
2+
3+
## Prose Tests
4+
5+
### Test that the driver accepts an arbitrary auth mechanism
6+
7+
1. Mock the server response in a way that `saslSupportedMechs` array in the `hello` command response contains an
8+
arbitrary string.
9+
10+
2. Create and connect a `Connection` object that connects to the server that returns the mocked response.
11+
12+
3. Assert that no error is raised.

0 commit comments

Comments
 (0)