Skip to content

Commit 174d5cb

Browse files
committed
DRIVERS-3207: Custom AWS credential providers execute first
1 parent eb7f9a2 commit 174d5cb

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

source/auth/auth.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,10 @@ Examples are provided below.
959959
960960
Drivers MUST allow the user to specify an AWS session token for authentication with temporary credentials.
961961
962+
- AWS_CREDENTIAL_PROVIDER
963+
964+
Drivers MAY allow the user to specify a custom credential provider object or function.
965+
962966
#### Obtaining Credentials
963967
964968
Drivers will need AWS IAM credentials (an access key, a secret access key and optionally a session token) to complete
@@ -1005,9 +1009,9 @@ Drivers MAY expose API for default providers for the following scenarios when ap
10051009

10061010
The order in which Drivers MUST search for credentials is:
10071011

1008-
1. The URI
1009-
2. Environment variables
1010-
3. A custom AWS credential provider if the driver supports it.
1012+
1. A custom AWS credential provider if the driver supports it.
1013+
2. The URI
1014+
3. Environment variables
10111015
4. Using `AssumeRoleWithWebIdentity` if `AWS_WEB_IDENTITY_TOKEN_FILE` and `AWS_ROLE_ARN` are set.
10121016
5. The ECS endpoint if `AWS_CONTAINER_CREDENTIALS_RELATIVE_URI` is set. Otherwise, the EC2 endpoint.
10131017

source/auth/tests/mongodb-aws.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,21 @@ SecretAccessKey=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
2121
Token=AQoDYXdzEJr...<remainder of security token>
2222
```
2323

24-
If the driver supports user provided custom AWS credential providers, then the driver MUST also test the above scenarios
25-
2-6 with a user provided `AWS_CREDENTIAL_PROVIDER` auth mechanism property. This value MUST be the default credential
26-
provider from the AWS SDK. If the default provider does not cover all scenarios above, those not covered MAY be skipped.
27-
In these tests the driver MUST also assert that the user provided credential provider was called at least once in each
28-
test.
29-
30-
If the driver supports a custom AWS credential provider, it MUST verify the custom provider was used when testing. This
31-
may be via a custom function or object that wraps the calls to the custom provider and asserts that it was called at
32-
least once.
24+
## Testing custom credential providers
25+
26+
If the driver supports custom AWS credential providers, the driver MUST test the following:
27+
28+
Scenario 1 from the previous section where the `ACCESS_KEY_ID` and `SECRET_ACCESS_KEY` pair are provided as client
29+
options, but are incorrect, and a custom `AWS_CREDENTIAL_PROVIDER` that returns the correct values for these two
30+
properties.
31+
32+
Scenarios 2-6 from the previous section with a user provided `AWS_CREDENTIAL_PROVIDER` auth mechanism property. This
33+
value MUST be the default credential provider from the AWS SDK. If the default provider does not cover all scenarios
34+
above, those not covered MAY be skipped. In these tests the driver MUST also assert that the user provided credential
35+
provider was called at least once in each test.
36+
37+
The driver MUST verify the custom provider was used when testing. This may be via a custom function or object that wraps
38+
the calls to the custom provider and asserts that it was called at least once.
3339

3440
## Regular credentials
3541

0 commit comments

Comments
 (0)