Skip to content

Commit 0e7430d

Browse files
committed
wip
1 parent 657315f commit 0e7430d

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/cmap/connect.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import {
1717
needsRetryableWriteLabel
1818
} from '../error';
1919
import { type IO } from '../mongo_client';
20-
import { type Monitor, type RTTPinger } from '../sdam/monitor';
2120
import { HostAddress, ns, promiseWithResolvers } from '../utils';
2221
import { AuthContext } from './auth/auth_provider';
2322
import { AuthMechanism } from './auth/providers';
@@ -27,7 +26,6 @@ import {
2726
type ConnectionOptions,
2827
CryptoConnection
2928
} from './connection';
30-
import { type ConnectionPool } from './connection_pool';
3129
import {
3230
MAX_SUPPORTED_SERVER_VERSION,
3331
MAX_SUPPORTED_WIRE_VERSION,

src/mongo_client_auth_providers.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ import { type MongoClient } from './mongo_client';
1616
/** @internal */
1717
const AUTH_PROVIDERS = new Map<
1818
AuthMechanism | string,
19-
(authMechanismProperties: AuthMechanismProperties) => AuthProvider
19+
(client: MongoClient, authMechanismProperties: AuthMechanismProperties) => AuthProvider
2020
>([
2121
[
2222
AuthMechanism.MONGODB_AWS,
23-
({ AWS_CREDENTIAL_PROVIDER }) => new MongoDBAWS(AWS_CREDENTIAL_PROVIDER)
23+
(_, { AWS_CREDENTIAL_PROVIDER }) => new MongoDBAWS(AWS_CREDENTIAL_PROVIDER)
2424
],
2525
[
2626
AuthMechanism.MONGODB_CR,
@@ -31,7 +31,10 @@ const AUTH_PROVIDERS = new Map<
3131
}
3232
],
3333
[AuthMechanism.MONGODB_GSSAPI, () => new GSSAPI()],
34-
[AuthMechanism.MONGODB_OIDC, properties => new MongoDBOIDC(getWorkflow(properties))],
34+
[
35+
AuthMechanism.MONGODB_OIDC,
36+
(client, properties) => new MongoDBOIDC(getWorkflow(client, properties))
37+
],
3538
[AuthMechanism.MONGODB_PLAIN, () => new Plain()],
3639
[AuthMechanism.MONGODB_SCRAM_SHA1, () => new ScramSHA1()],
3740
[AuthMechanism.MONGODB_SCRAM_SHA256, () => new ScramSHA256()],
@@ -74,7 +77,7 @@ export class MongoClientAuthProviders {
7477
throw new MongoInvalidArgumentError(`authMechanism ${name} not supported`);
7578
}
7679

77-
const provider = providerFunction(authMechanismProperties);
80+
const provider = providerFunction(this.client, authMechanismProperties);
7881
this.existingProviders.set(name, provider);
7982
return provider;
8083
}
@@ -83,14 +86,17 @@ export class MongoClientAuthProviders {
8386
/**
8487
* Gets either a device workflow or callback workflow.
8588
*/
86-
function getWorkflow(authMechanismProperties: AuthMechanismProperties): Workflow {
89+
function getWorkflow(
90+
client: MongoClient,
91+
authMechanismProperties: AuthMechanismProperties
92+
): Workflow {
8793
if (authMechanismProperties.OIDC_HUMAN_CALLBACK) {
8894
return new HumanCallbackWorkflow(new TokenCache(), authMechanismProperties.OIDC_HUMAN_CALLBACK);
8995
} else if (authMechanismProperties.OIDC_CALLBACK) {
9096
return new AutomatedCallbackWorkflow(new TokenCache(), authMechanismProperties.OIDC_CALLBACK);
9197
} else {
9298
const environment = authMechanismProperties.ENVIRONMENT;
93-
const workflow = OIDC_WORKFLOWS.get(environment)?.(this.client);
99+
const workflow = OIDC_WORKFLOWS.get(environment)?.(client);
94100
if (!workflow) {
95101
throw new MongoInvalidArgumentError(
96102
`Could not load workflow for environment ${authMechanismProperties.ENVIRONMENT}`

0 commit comments

Comments
 (0)