Skip to content

Conversation

durran
Copy link
Member

@durran durran commented Sep 28, 2025

Description

Removes the ability to provide credentials when using MONGODB-AWS authentication.

Summary of Changes

  • Updates drivers tools to get the --nouri option for aws_tester.py
  • Sets up CI environments without credentials in the MONGODB_URI
  • Skips no longer relevant legacy auth tests.
  • Adds new tests in the legacy auth tests for testing error conditions
  • Removes support for providing credentials in the URI or options when auth mech is MONGODB-AWS.
Notes for Reviewers

I made AWS_SESSION_TOKEN internal instead of removing it completely as we still use that object and property internally when fetching credentials.

What is the motivation for this change?

NODE-7046/DRIVERS-3131

Release Highlight

Explicitly Provided Credentials No Longer Accepted With MONGODB-AWS Authentication

AWS environments (such as AWS Lambda) do not have credentials that are permanent and expire within a set amount of time. Providing credentials in the URI or options would mandate that those credentials would be valid for the life of the MongoClient, which is problematic. With this change, the installed required AWS SDK will now fetch credentials using the environment, endpoints, or a custom credential provider.

This means that for AWS authentication, all client URIs MUST now be specified as:

import { MongoClient } from 'mongodb';

const client = new MongoClient('mongodb<+srv>://<host>:<port>/?authMechanism=MONGODB-AWS');

Double check the following

  • Lint is passing (npm run check:lint)
  • Self-review completed using the steps outlined here
  • PR title follows the correct format: type(NODE-xxxx)[!]: description
    • Example: feat(NODE-1234)!: rewriting everything in coffeescript
  • Changes are covered by tests
  • New TODOs have a related JIRA ticket

@durran durran changed the title feat(NODE-7046): remove AWS uri support feat(NODE-7046): remove AWS uri/options support Sep 30, 2025
@durran durran marked this pull request as ready for review September 30, 2025 16:39
@durran durran requested a review from a team as a code owner September 30, 2025 16:39
@dariakp dariakp self-assigned this Oct 1, 2025
@dariakp dariakp added the Primary Review In Review with primary reviewer, not yet ready for team's eyes label Oct 1, 2025
if (isAws) {
const { username, password } = mongoOptions.credentials;
if (username || password) {
throw new MongoParseError(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're trying to move away from using MongoParseError for options that we are able to read but that happen to be invalid (see NODE-4015), can we go with MongoAPIError for both of the new instances here?

);
}
if (mongoOptions.credentials.mechanismProperties.AWS_SESSION_TOKEN) {
throw new MongoParseError('AWS_SESSION_TOKEN cannot be provided when using MONGODB-AWS');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we update both of these messages to hint at the correct way to provide the credentials?

}
}
},
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bookmark for corresponding spec update

mechanism: MONGODB-AWS
mechanism_properties:
AWS_SESSION_TOKEN: token!@#$%^&*()_+
- description: should throw an exception if username provided (MONGODB-AWS)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bookmark for corresponding spec update

for (const test of suite.tests) {
it(`${test.description}`, function () {
if (SKIP.includes(test.description)) {
this.test.skipReason = `NODE-7046: ${test.description}`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bookmark for the deletion ticket (once the DRIVERS ticket is filed, we can generate the language tickets and then add the NODE ticket reference here)

import { executeUriValidationTest } from '../../tools/uri_spec_runner';

const SKIP = [
'should throw an exception if username and no password (MONGODB-AWS)',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect we can leave this one unskipped, since it should continue to fail (albeit for a different reason), but no strong preference since we should get the same coverage from the newly added test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Primary Review In Review with primary reviewer, not yet ready for team's eyes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants