Skip to content

Commit 04f8677

Browse files
committed
feat(NODE-7047): use custom credential provider first
1 parent 1634d19 commit 04f8677

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

src/cmap/auth/mongodb_aws.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ export class MongoDBAWS extends AuthProvider {
6363
);
6464
}
6565

66-
if (!authContext.credentials.username) {
66+
// If a custom credential provider is present we will use that first.
67+
if (this.credentialProvider || !authContext.credentials.username) {
6768
authContext.credentials = await makeTempCredentials(
6869
authContext.credentials,
6970
this.credentialFetcher

test/integration/auth/mongodb_aws.test.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,6 @@ describe('MONGODB-AWS', function () {
144144
this.skipReason = 'only relevant to AssumeRoleWithWebIdentity with SDK installed';
145145
return this.skip();
146146
}
147-
// If we have a username the credentials have been set from the URI, options, or environment
148-
// variables per the auth spec stated order.
149-
if (client.options.credentials.username) {
150-
this.skipReason = 'Credentials in the URI on env variables will not use custom provider.';
151-
return this.skip();
152-
}
153147
});
154148

155149
it('authenticates with a user provided credentials provider', async function () {

0 commit comments

Comments
 (0)