Skip to content

Conversation

durran
Copy link
Member

@durran durran commented Sep 9, 2025

Updates the AWS auth spec to require drivers that implement custom AWS credential providers to use the custom provider before any other method.

Updates test wording to include the extra scenario for testing a custom provider when explicit credentials are also provided.

Node implementation: mongodb/node-mongodb-native#4656

Please complete the following before merging:

  • Update changelog.
  • Test changes in at least one language driver.
  • Test these changes against all server versions and topologies (including standalone, replica set, and sharded
    clusters).

@durran durran force-pushed the DRIVERS-3207 branch 2 times, most recently from 174d5cb to b2ae9b3 Compare September 9, 2025 18:03
@durran durran marked this pull request as ready for review September 10, 2025 12:47
@durran durran requested a review from a team as a code owner September 10, 2025 12:47
@durran durran requested review from JamesKovacs and removed request for a team September 10, 2025 12:47
If the driver supports a custom AWS credential provider, it MUST verify the custom provider was used when testing. This
may be via a custom function or object that wraps the calls to the custom provider and asserts that it was called at
least once.
## Testing custom credential providers
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have any tests that test the precedence that drivers use when fetching credentials?a

Copy link
Member Author

Choose a reason for hiding this comment

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

We do not, as our drivers tools scripts only set up one type of credential per test, not multiples.

Comment on lines 1012 to 1014
1. A custom AWS credential provider if the driver supports it.
2. The URI
3. Environment variables
Copy link
Contributor

Choose a reason for hiding this comment

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

I would expect that the URI takes precedence over any dynamic credential loading mechanism and that the custom credential provider should be the first place we look for credentials, if they're not explicitly provided.

Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that is the fundamental question posed in this spec change (the DRIVERS ticket AC leaves this open ended) - it may be helpful to have this conversation in slack with the auth spec owners;

notably, for encryption, the URI isn't relevant, but this spec change as a whole would affect automatic credential fetching - should we add a test there, too? (e.g., see Case 15 and 26)

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not too concerned about it here, since we won't even look at the URI after DRIVERS-3131 is implemented. This is all assuming in this case that the auth mechanism is MONGODB-AWS - I still think even before DRIVERS-3131 if a custom provider is supplied, that it should take preference over all, since it's provided as an option to the client and not a URI option, and we've set the standard that programmatic options always take preference over URI options.

Copy link
Contributor

Choose a reason for hiding this comment

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

We do have a standard that equivalent MongoClient options take precedence over URI options, but we don't have precedent for a MongoClient option to take precedence over a related but different URI option. The current behavior is such that if credentials are provided in the URI, we do not attempt to fetch credentials. While it is true that Node will drop support for explicitly specified credentials, other drivers might not (they need to wait for a major release) and so we do need to consider explicitly provided credentials here.

My thought is that we should preserve the existing behavior: explicitly provided credentials first, then attempt to fetch credentials. If fetching credentials, use the custom provider first.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok I've moved URI options back to #1 now.

Comment on lines 1012 to 1014
1. A custom AWS credential provider if the driver supports it.
2. The URI
3. Environment variables
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that is the fundamental question posed in this spec change (the DRIVERS ticket AC leaves this open ended) - it may be helpful to have this conversation in slack with the auth spec owners;

notably, for encryption, the URI isn't relevant, but this spec change as a whole would affect automatic credential fetching - should we add a test there, too? (e.g., see Case 15 and 26)

3. A custom AWS credential provider if the driver supports it.
1. A custom AWS credential provider if the driver supports it.
2. The URI
3. Environment variables
4. Using `AssumeRoleWithWebIdentity` if `AWS_WEB_IDENTITY_TOKEN_FILE` and `AWS_ROLE_ARN` are set.
5. The ECS endpoint if `AWS_CONTAINER_CREDENTIALS_RELATIVE_URI` is set. Otherwise, the EC2 endpoint.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's make sure to remember to update the changelog

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated.

@dariakp dariakp self-assigned this Sep 10, 2025
@durran
Copy link
Member Author

durran commented Sep 11, 2025

#1838 (comment)

I have added a prose test for FLE in case 26. Case 15 I don't believe is relevant as it pertains to automatic credential fetching, which means nothing is provided. Even with the changes in this PR the order on automatic credential fetching is the same.

@durran durran requested a review from a team as a code owner September 11, 2025 13:29
@durran durran requested review from katcharov and removed request for a team September 11, 2025 13:29
@durran
Copy link
Member Author

durran commented Sep 11, 2025

#1838 (comment)

Added link.

@durran durran changed the title DRIVERS-3207: Custom AWS credential providers execute first DRIVERS-3207: Custom AWS credential providers execute earlier Sep 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants