Skip to content
This repository was archived by the owner on May 31, 2022. It is now read-only.

Commit a8ef198

Browse files
authored
chore: remove kerberos password COMPASS-4378 (#343)
1 parent 802fae6 commit a8ef198

File tree

9 files changed

+128
-269
lines changed

9 files changed

+128
-269
lines changed

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,11 @@ console.log(c.driverOptions)
204204
const c = new Connection({
205205
kerberosServiceName: 'mongodb',
206206
kerberosPrincipal: 'arlo/dog@krb5.mongodb.parts',
207-
kerberosPassword: 'w@@f',
208207
ns: 'toys'
209208
});
210209

211210
console.log(c.driverUrl)
212-
>>> 'mongodb://arlo%252Fdog%2540krb5.mongodb.parts:w%40%40f@localhost:27017/toys?slaveOk=true&gssapiServiceName=mongodb&authMechanism=GSSAPI'
211+
>>> 'mongodb://arlo%252Fdog%2540krb5.mongodb.parts@localhost:27017/toys?slaveOk=true&gssapiServiceName=mongodb&authMechanism=GSSAPI'
213212

214213
console.log(c.driverOptions)
215214
>>> {
@@ -224,7 +223,6 @@ console.log(c.driverOptions)
224223
| ----- | ---- | ---------- | ---- |
225224
| `kerberosServiceName` | String | Any program or computer you access over a network | `undefined` |
226225
| `kerberosPrincipal` | String | The format of a typical Kerberos V5 principal is `primary/instance@REALM` | `undefined` |
227-
| `kerberosPassword` | String | You can optionally include a password for a kerberos connection | `undefined` |
228226
| `kerberosCanonicalizeHostname` | Boolean | Whether canonicalized kerberos hostname | `undefined` |
229227

230228
#### See Also

constants/auth-strategy-to-field-names.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ module.exports = {
1313
],
1414
KERBEROS: [
1515
'kerberosPrincipal', // required
16-
'kerberosPassword', // optional
1716
'kerberosServiceName', // optional
1817
'kerberosCanonicalizeHostname'
1918
],

lib/model.js

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ const DRIVER_OPTIONS_DEFAULT = { connectWithNoPrimary: true };
5353
*/
5454
const PASSWORD_MAPPINGS = {
5555
mongodb_password: 'mongodbPassword',
56-
kerberos_password: 'kerberosPassword',
5756
ldap_password: 'ldapPassword',
5857
ssl_private_key_password: 'sslPass',
5958
ssh_tunnel_password: 'sshTunnelPassword',
@@ -221,12 +220,11 @@ assign(props, {
221220
* @example
222221
* const c = new Connection({
223222
* kerberosServiceName: 'mongodb',
224-
* kerberosPassword: 'w@@f',
225223
* kerberosPrincipal: 'arlo/dog@krb5.mongodb.parts',
226224
* ns: 'kerberos'
227225
* });
228226
* console.log(c.driverUrl)
229-
* >>> mongodb://arlo%252Fdog%2540krb5.mongodb.parts:w%40%40f@localhost:27017/kerberos?slaveOk=true&gssapiServiceName=mongodb&authMechanism=GSSAPI
227+
* >>> mongodb://arlo%252Fdog%2540krb5.mongodb.parts@localhost:27017/kerberos?slaveOk=true&gssapiServiceName=mongodb&authMechanism=GSSAPI
230228
* console.log(c.driverOptions)
231229
* >>> { db: { readPreference: 'nearest' }, replSet: { connectWithNoPrimary: true } }
232230
*
@@ -255,14 +253,6 @@ assign(props, {
255253
* `mongodb://#{encodeURIComponentRFC3986(this.kerberosPrincipal)}`
256254
*/
257255
kerberosPrincipal: { type: 'string', default: undefined },
258-
/**
259-
* You can optionally include a password for a kerberos connection.
260-
* Including a password is useful on windows if you don’t have a
261-
* security domain set up.
262-
* If no password is supplied, it is expected that a valid kerberos
263-
* ticket has already been created for the principal.
264-
*/
265-
kerberosPassword: { type: 'string', default: undefined },
266256
kerberosCanonicalizeHostname: { type: 'boolean', default: false }
267257
});
268258

@@ -469,15 +459,9 @@ function addAuthToUrl({ url, isPasswordProtected }) {
469459
} else if (this.authStrategy === 'X509' && this.x509Username) {
470460
username = encodeURIComponentRFC3986(this.x509Username);
471461
authField = username;
472-
} else if (this.authStrategy === 'KERBEROS' && this.kerberosPassword) {
473-
username = encodeURIComponentRFC3986(this.kerberosPrincipal);
474-
password = isPasswordProtected
475-
? '*****'
476-
: encodeURIComponentRFC3986(this.kerberosPassword);
477-
authField = format('%s:%s', username, password);
478462
} else if (this.authStrategy === 'KERBEROS') {
479463
username = encodeURIComponentRFC3986(this.kerberosPrincipal);
480-
authField = format('%s:', username);
464+
authField = format('%s', username);
481465
}
482466

483467
// The auth component comes straight after `the mongodb://`
@@ -925,15 +909,6 @@ Connection = AmpersandModel.extend({
925909
)
926910
);
927911
}
928-
if (attrs.kerberosPassword) {
929-
throw new TypeError(
930-
format(
931-
'The Kerberos \'Password\' field does not apply when ' +
932-
'using %s for authentication.',
933-
attrs.authStrategy
934-
)
935-
);
936-
}
937912
} else if (!attrs.kerberosPrincipal) {
938913
throw new TypeError(
939914
'The Kerberos \'Principal\' field is required when using \'Kerberos\' for authentication.'
@@ -1122,7 +1097,6 @@ async function createConnectionFromUrl(url) {
11221097
attrs.x509Username = user;
11231098
} else if (attrs.authStrategy === 'KERBEROS') {
11241099
attrs.kerberosPrincipal = user;
1125-
attrs.kerberosPassword = password;
11261100
} else if (
11271101
attrs.authStrategy === 'MONGODB' ||
11281102
attrs.authStrategy === 'SCRAM-SHA-256'

0 commit comments

Comments
 (0)