Skip to content

Commit

Permalink
revert new logic when parsing authMechanismProperties
Browse files Browse the repository at this point in the history
  • Loading branch information
baileympearson committed Feb 11, 2022
1 parent 9edcfe6 commit 54c5560
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions src/connection_string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -632,35 +632,26 @@ export const OPTIONS = {
},
authMechanismProperties: {
target: 'credentials',
transform({ options, values: [value] }): MongoCredentials {
if (typeof value === 'string') {
const validKeys = [
'SERVICE_NAME',
'SERVICE_REALM',
'CANONICALIZE_HOST_NAME',
'AWS_SESSION_TOKEN'
];

transform({ options, values: [optionValue] }): MongoCredentials {
if (typeof optionValue === 'string') {
const mechanismProperties = Object.create(null);

for (const [key, _value] of entriesFromString(value)) {
if (validKeys.includes(key)) {
if (key === 'CANONICALIZE_HOST_NAME') {
mechanismProperties[key] = getBoolean(key, _value);
} else {
mechanismProperties[key] = _value;
}
for (const [key, value] of entriesFromString(optionValue)) {
try {
mechanismProperties[key] = getBoolean(key, value);
} catch {
mechanismProperties[key] = value;
}
}

return MongoCredentials.merge(options.credentials, {
mechanismProperties
});
}
if (!isRecord(value)) {
if (!isRecord(optionValue)) {
throw new MongoParseError('AuthMechanismProperties must be an object');
}
return MongoCredentials.merge(options.credentials, { mechanismProperties: value });
return MongoCredentials.merge(options.credentials, { mechanismProperties: optionValue });
}
},
authSource: {
Expand Down

0 comments on commit 54c5560

Please sign in to comment.