File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -93,6 +93,8 @@ type EnvironmentName = 'test' | 'azure' | 'gcp' | 'k8s' | undefined;
93
93
94
94
/** @internal */
95
95
export interface Workflow {
96
+ cache : TokenCache ;
97
+
96
98
/**
97
99
* All device workflows must implement this method in order to get the access
98
100
* token and then call authenticate with it.
Original file line number Diff line number Diff line change @@ -61,6 +61,7 @@ import {
61
61
WaitQueueTimeoutError
62
62
} from './errors' ;
63
63
import { ConnectionPoolMetrics } from './metrics' ;
64
+ import { MongoDBOIDC } from './auth/mongodb_oidc' ;
64
65
65
66
/** @public */
66
67
export interface ConnectionPoolOptions extends Omit < ConnectionOptions , 'id' | 'generation' > {
@@ -428,6 +429,19 @@ export class ConnectionPool extends TypedEventEmitter<ConnectionPoolEvents> {
428
429
return ;
429
430
}
430
431
432
+ // If we are clearing the connnection pool when using OIDC, we need to remove the access token
433
+ // from the cache so we dont' try to use the same token again for initial auth on a new connection
434
+ // when the token may have expired.
435
+ const clientState = this . server . topology . client . s ;
436
+ const credentials = clientState . options . credentials ;
437
+ if ( credentials ?. mechanism === 'MONGODB-OIDC' ) {
438
+ const provider = this . server . topology . client . s . authProviders . getOrCreateProvider (
439
+ credentials . mechanism ,
440
+ credentials . mechanismProperties
441
+ ) as MongoDBOIDC ;
442
+ provider . workflow . cache . removeAccessToken ( ) ;
443
+ }
444
+
431
445
// handle load balanced case
432
446
if ( this . loadBalanced ) {
433
447
const { serviceId } = options ;
You can’t perform that action at this time.
0 commit comments