@@ -380,6 +380,7 @@ class AutoEncryptionOpts {
380
380
// without the MongoDB Enterprise Advanced licensed crypt_shared library.
381
381
bypassQueryAnalysis: Optional <Boolean >; // Default false.
382
382
keyExpirationMS: Optional <Uint64 >; // Default 60000. 0 means "never expire".
383
+ credentialProviders: Optional <CredentialProviders >;
383
384
}
384
385
```
385
386
475
476
<span id =" GCPKMSOptions " ></span > <span id =" AWSKMSOptions " ></span > <span id =" KMSProvider " ></span >
476
477
<span id =" KMSProviders " ></span > <span id =" AzureAccessToken " ></span > <span id =" kmsproviders " ></span >
477
478
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
+
478
517
#### kmsProviders
479
518
480
519
The ` kmsProviders ` property may be specified on [ClientEncryptionOpts](#ClientEncryptionOpts) or
@@ -593,11 +632,14 @@ Once requested, drivers MUST create a new [KMSProviders](#kmsproviders) $P$ acco
593
632
[ClientEncryptionOpts](#ClientEncryptionOpts) or [AutoEncryptionOpts](#AutoEncryptionOpts).
594
633
2. Initialize $P$ to an empty [KMSProviders](#kmsproviders) object.
595
634
3. 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.
601
643
4. If $K$ contains an ` gcp ` property, and that property is an empty map:
602
644
1. Attempt to obtain credentials $C$ from the environment logic as is detailed in
603
645
[Obtaining GCP Credentials](#obtaining-gcp-credentials).
@@ -1051,6 +1093,7 @@ interface ClientEncryptionOpts {
1051
1093
keyVaultClient: MongoClient ;
1052
1094
keyVaultNamespace : String ;
1053
1095
kmsProviders : KMSProviders ;
1096
+ credentialProviders : CredentialProviders ;
1054
1097
tlsOptions ?: KMSProvidersTLSOptions ; // Maps KMS provider to TLS options.
1055
1098
keyExpirationMS : Optional < Uint64 > ; // Default 60000. 0 means "never expire".
1056
1099
};
@@ -2420,6 +2463,8 @@ explicit session parameter as described in the [Drivers Sessions Specification](
2420
2463
2421
2464
## Changelog
2422
2465
2466
+ - 2024 -02 -19 : Add custom options AWS credential provider .
2467
+
2423
2468
- 2024 -10 -09 : Add retry prose test .
2424
2469
2425
2470
- 2024 -07 -29 : Document range as stable .
0 commit comments