Skip to content

Commit 5caa354

Browse files
authored
fix(NODE-2026): SERVICE_REALM kerberos mechanism property not attached (#2865)
1 parent 27cf1d2 commit 5caa354

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

src/cmap/auth/gssapi.ts

+10-8
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import type { Document } from '../../bson';
77
type MechanismProperties = {
88
gssapiCanonicalizeHostName?: boolean;
99
SERVICE_NAME?: string;
10+
SERVICE_REALM?: string;
1011
};
1112

1213
import * as dns from 'dns';
@@ -90,14 +91,15 @@ function makeKerberosClient(authContext: AuthContext, callback: Callback<Kerbero
9091
Object.assign(initOptions, { user: username, password: password });
9192
}
9293

93-
initializeClient(
94-
`${serviceName}${process.platform === 'win32' ? '/' : '@'}${host}`,
95-
initOptions,
96-
(err: string, client: KerberosClient): void => {
97-
if (err) return callback(new MongoDriverError(err));
98-
callback(undefined, client);
99-
}
100-
);
94+
let spn = `${serviceName}${process.platform === 'win32' ? '/' : '@'}${host}`;
95+
if ('SERVICE_REALM' in mechanismProperties) {
96+
spn = `${spn}@${mechanismProperties.SERVICE_REALM}`;
97+
}
98+
99+
initializeClient(spn, initOptions, (err: string, client: KerberosClient): void => {
100+
if (err) return callback(new MongoDriverError(err));
101+
callback(undefined, client);
102+
});
101103
}
102104
);
103105
}

test/manual/kerberos.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ describe('Kerberos', function () {
5050
});
5151
});
5252

53-
// TODO: this test only tests that these properties do not crash anything - but not that they actually have an effect
54-
it('validate that SERVICE_REALM and CANONICALIZE_HOST_NAME can be passed in', function (done) {
53+
// Unskip this test when a proper setup is available - see NODE-3060
54+
it.skip('validate that SERVICE_REALM and CANONICALIZE_HOST_NAME can be passed in', function (done) {
5555
const client = new MongoClient(
5656
`${krb5Uri}&authMechanismProperties=SERVICE_NAME:mongodb,CANONICALIZE_HOST_NAME:false,SERVICE_REALM:windows&maxPoolSize=1`
5757
);

0 commit comments

Comments
 (0)