Skip to content

Commit a7d1802

Browse files
committed
feat: set credential provider as auth mech prop
1 parent cb0e465 commit a7d1802

File tree

4 files changed

+5
-14
lines changed

4 files changed

+5
-14
lines changed

src/cmap/auth/mongo_credentials.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
MongoInvalidArgumentError,
77
MongoMissingCredentialsError
88
} from '../../error';
9+
import type { AWSCredentialProvider } from './aws_temporary_credentials';
910
import { GSSAPICanonicalizationValue } from './gssapi';
1011
import type { OIDCCallbackFunction } from './mongodb_oidc';
1112
import { AUTH_MECHS_AUTH_SRC_EXTERNAL, AuthMechanism } from './providers';
@@ -68,6 +69,8 @@ export interface AuthMechanismProperties extends Document {
6869
ALLOWED_HOSTS?: string[];
6970
/** The resource token for OIDC auth in Azure and GCP. */
7071
TOKEN_RESOURCE?: string;
72+
/** A custom AWS credential provider to use. */
73+
AWS_CREDENTIAL_PROVIDER?: AWSCredentialProvider;
7174
}
7275

7376
/** @public */

src/connection_string.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import ConnectionString from 'mongodb-connection-string-url';
33
import { URLSearchParams } from 'url';
44

55
import type { Document } from './bson';
6-
import { type AWSCredentialProvider } from './cmap/auth/aws_temporary_credentials';
76
import { MongoCredentials } from './cmap/auth/mongo_credentials';
87
import { AUTH_MECHS_AUTH_SRC_EXTERNAL, AuthMechanism } from './cmap/auth/providers';
98
import { addContainerMetadata, makeClientMetadata } from './cmap/handshake/client_metadata';
@@ -752,14 +751,6 @@ export const OPTIONS = {
752751
autoSelectFamilyAttemptTimeout: {
753752
type: 'uint'
754753
},
755-
awsCredentialsProvider: {
756-
transform({ values: [value] }): AWSCredentialProvider {
757-
if (typeof value === 'function') {
758-
return value as AWSCredentialProvider;
759-
}
760-
throw new MongoParseError(`Option awsCredentialProvider must be a function, got ${value}`);
761-
}
762-
},
763754
bsonRegExp: {
764755
type: 'boolean'
765756
},

src/mongo_client.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import type { ConnectionOptions as TLSConnectionOptions, TLSSocketOptions } from
55
import { type BSONSerializeOptions, type Document, resolveBSONOptions } from './bson';
66
import { ChangeStream, type ChangeStreamDocument, type ChangeStreamOptions } from './change_stream';
77
import type { AutoEncrypter, AutoEncryptionOptions } from './client-side-encryption/auto_encrypter';
8-
import { type AWSCredentialProvider } from './cmap/auth/aws_temporary_credentials';
98
import {
109
type AuthMechanismProperties,
1110
DEFAULT_ALLOWED_HOSTS,
@@ -300,10 +299,6 @@ export interface MongoClientOptions extends BSONSerializeOptions, SupportedNodeC
300299
* TODO: NODE-5671 - remove internal flag
301300
*/
302301
mongodbLogMaxDocumentLength?: number;
303-
/**
304-
* A custom AWS SDK credentials provider to use instead of the default.
305-
*/
306-
awsCredentialsProvider?: AWSCredentialProvider;
307302

308303
/** @internal */
309304
__skipPingOnConnect?: boolean;

src/mongo_client_auth_providers.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ export class MongoClientAuthProviders {
6969
let provider;
7070
if (name === AuthMechanism.MONGODB_OIDC) {
7171
provider = providerFunction(this.getWorkflow(authMechanismProperties));
72+
} else if (name === AuthMechanism.MONGODB_AWS) {
73+
provider = providerFunction(authMechanismProperties.AWS_CREDENTIAL_PROVIDER);
7274
} else {
7375
provider = providerFunction();
7476
}

0 commit comments

Comments
 (0)