Skip to content
10 changes: 7 additions & 3 deletions source/auth/auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,10 @@ Examples are provided below.
Drivers MUST allow the user to specify an AWS session token for authentication with temporary credentials.
- AWS_CREDENTIAL_PROVIDER
Drivers MAY allow the user to specify a custom credential provider object or function.
#### Obtaining Credentials
Drivers will need AWS IAM credentials (an access key, a secret access key and optionally a session token) to complete
Expand Down Expand Up @@ -1005,9 +1009,9 @@ Drivers MAY expose API for default providers for the following scenarios when ap

The order in which Drivers MUST search for credentials is:

1. The URI
2. Environment variables
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.

Expand Down
20 changes: 11 additions & 9 deletions source/auth/tests/mongodb-aws.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@ SecretAccessKey=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Token=AQoDYXdzEJr...<remainder of security token>
```

If the driver supports user provided custom AWS credential providers, then the driver MUST also test the above scenarios
2-6 with a user provided `AWS_CREDENTIAL_PROVIDER` auth mechanism property. This value MUST be the default credential
provider from the AWS SDK. If the default provider does not cover all scenarios above, those not covered MAY be skipped.
In these tests the driver MUST also assert that the user provided credential provider was called at least once in each
test.

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

If the driver supports custom AWS credential providers, the driver MUST test the following:

Scenarios 1-6 from the previous section with a user provided `AWS_CREDENTIAL_PROVIDER` auth mechanism property. This
value MAY be the default credential provider from the AWS SDK. If the default provider does not cover all scenarios
above, those not covered MAY be skipped. In these tests the driver MUST also assert that the user provided credential
provider was called in each test. 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. For test scenarios where the drivers tools scripts put the
credentials in the MONGODB_URI, drivers MAY extract the credentials from the URI and return the AWS credentials directly
from the custom provider instead of using the AWS SDK default provider.

## Regular credentials

Expand Down
Loading