@@ -380,6 +380,7 @@ class AutoEncryptionOpts {
380380 // without the MongoDB Enterprise Advanced licensed crypt_shared library.
381381 bypassQueryAnalysis: Optional <Boolean >; // Default false.
382382 keyExpirationMS: Optional <Uint64 >; // Default 60000. 0 means "never expire".
383+ credentialProviders: Optional <CredentialProviders >;
383384}
384385```
385386
475476<span id =" GCPKMSOptions " ></span > <span id =" AWSKMSOptions " ></span > <span id =" KMSProvider " ></span >
476477<span id =" KMSProviders " ></span > <span id =" AzureAccessToken " ></span > <span id =" kmsproviders " ></span >
477478
479+ #### credentialProviders
480+
481+ The ` credentialProviders ` property may be specified on [ ClientEncryptionOpts] ( #ClientEncryptionOpts ) or
482+ [ AutoEncryptionOpts] ( #AutoEncryptionOpts ) . Current support is for AWS only, but is designed to be able to accommodate
483+ additional providers in the future. If a custom credential provider is present, it MUST be used instead of the default
484+ flow for fetching automatic credentials and if the ` kmsProviders ` are not configured for automatic credential fetching
485+ an error MUST be thrown.
486+
487+ ``` typescript
488+ interface CredentialProviders {
489+ aws? : AWSCredentialProvider
490+ }
491+
492+ // The type of the AWS credential provider is dictated by the AWS SDK's credential provider for the specific
493+ // language.
494+ type AWSCredentialProvider = Function | Object ;
495+ ```
496+
497+ The following shows an example object of ` CredentialProviders ` for Node.js:
498+
499+ ``` typescript
500+ import { fromNodeProviderChain } from ' @aws-sdk/credential-providers' ;
501+
502+ const client = new MongoClient (process .env .MONGODB_URI , {
503+ autoEncryption: {
504+ keyVaultNamespace: ' keyvault.datakeys' ,
505+ kmsProviders: {
506+ // Set to empty map to use `credentialProviders`.
507+ aws: {}
508+ },
509+ credentialProviders: {
510+ // Acquire credentials for AWS:
511+ aws: fromNodeProviderChain ()
512+ }
513+ }
514+ }
515+ ` ` `
516+
478517#### kmsProviders
479518
480519The ` kmsProviders ` property may be specified on [ClientEncryptionOpts](#ClientEncryptionOpts) or
@@ -593,11 +632,14 @@ Once requested, drivers MUST create a new [KMSProviders](#kmsproviders) $P$ acco
593632 [ClientEncryptionOpts](#ClientEncryptionOpts) or [AutoEncryptionOpts](#AutoEncryptionOpts).
5946332. Initialize $P$ to an empty [KMSProviders](#kmsproviders) object.
5956343. If $K$ contains an ` aws ` property, and that property is an empty map:
596- 1 . Attempt to obtain credentials $C$ from the environment using similar logic as is detailed in
597- [ the obtaining-AWS-credentials section from the Driver Authentication specification] ( ../auth/auth.md#obtaining-credentials ) ,
598- but ignoring the case of loading the credentials from a URI
599- 2 . If credentials $C$ were successfully loaded, create a new [ AWSKMSOptions] ( #AWSKMSOptions ) map from $C$ and insert
600- that map onto $P$ as the ` aws ` property.
635+ 1. If a custom credential provider is supplied via the ` credentialProviders .aws ` applicable encryption option, use
636+ that to fetch the credentials from AWS.
637+ 2. Otherwise:
638+ 1. Attempt to obtain credentials $C$ from the environment using similar logic as is detailed in
639+ [the obtaining-AWS-credentials section from the Driver Authentication specification](../auth/auth.md#obtaining-credentials),
640+ but ignoring the case of loading the credentials from a URI
641+ 2. If credentials $C$ were successfully loaded, create a new [AWSKMSOptions](#AWSKMSOptions) map from $C$ and
642+ insert that map onto $P$ as the ` aws ` property.
6016434. If $K$ contains an ` gcp ` property, and that property is an empty map:
602644 1. Attempt to obtain credentials $C$ from the environment logic as is detailed in
603645 [Obtaining GCP Credentials](#obtaining-gcp-credentials).
@@ -1051,6 +1093,7 @@ interface ClientEncryptionOpts {
10511093 keyVaultClient: MongoClient ;
10521094 keyVaultNamespace : String ;
10531095 kmsProviders : KMSProviders ;
1096+ credentialProviders : CredentialProviders ;
10541097 tlsOptions ?: KMSProvidersTLSOptions ; // Maps KMS provider to TLS options.
10551098 keyExpirationMS : Optional < Uint64 > ; // Default 60000. 0 means "never expire".
10561099};
@@ -2420,6 +2463,8 @@ explicit session parameter as described in the [Drivers Sessions Specification](
24202463
24212464## Changelog
24222465
2466+ - 2024 -02 -19 : Add custom options AWS credential provider .
2467+
24232468- 2024 -10 -09 : Add retry prose test .
24242469
24252470- 2024 -07 -29 : Document range as stable .
0 commit comments