File tree 1 file changed +17
-2
lines changed
1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -127,6 +127,7 @@ class CliRepl {
127
127
if ( this . isPasswordMissing ( driverOptions ) ) {
128
128
await this . requirePassword ( driverUri , driverOptions ) ;
129
129
}
130
+ this . ensurePasswordFieldIsPresentInAuth ( driverOptions ) ;
130
131
131
132
if ( ! this . cliOptions . quiet ) {
132
133
this . output . write ( `Current Mongosh Log ID:\t${ this . logId } \n` ) ;
@@ -393,9 +394,23 @@ class CliRepl {
393
394
* @returns {boolean } If the password is missing.
394
395
*/
395
396
isPasswordMissing ( driverOptions : MongoClientOptions ) : boolean {
396
- return ! ! ( driverOptions . auth &&
397
+ return ! ! (
398
+ driverOptions . auth &&
397
399
driverOptions . auth . username &&
398
- ! driverOptions . auth . password ) ;
400
+ ! driverOptions . auth . password &&
401
+ driverOptions . authMechanism !== 'GSSAPI' // no need for a password for Kerberos
402
+ ) ;
403
+ }
404
+
405
+ /**
406
+ * Sets the auth.password field to undefined in the driverOptions if the auth
407
+ * object is present with a truthy username. This is required by the driver, e.g.
408
+ * in the case of password-less Kerberos authentication.
409
+ */
410
+ ensurePasswordFieldIsPresentInAuth ( driverOptions : MongoClientOptions ) : void {
411
+ if ( driverOptions . auth && driverOptions . auth . username && ! ( 'password' in driverOptions . auth ) ) {
412
+ driverOptions . auth . password = undefined ;
413
+ }
399
414
}
400
415
401
416
/**
You can’t perform that action at this time.
0 commit comments