v6.7.0
6.7.0 (2024-05-29)
The MongoDB Node.js team is pleased to announce version 6.7.0 of the mongodb
package!
Release Notes
Support for MONGODB-OIDC Authentication
MONGODB-OIDC
is now supported as an authentication mechanism for MongoDB server versions 7.0+. The currently supported facets to authenticate with are callback authentication, human interaction callback authentication, Azure machine authentication, and GCP machine authentication.
Azure Machine Authentication
The MongoClient
must be instantiated with authMechanism=MONGODB-OIDC
in the URI or in the client options. Additional required auth mechanism properties of TOKEN_RESOURCE
and ENVIRONMENT
are required and another optional username can be provided. Example:
const client = new MongoClient('mongodb+srv://<username>@<host>:<port>/?authMechanism=MONGODB-OIDC&authMechanismProperties=TOKEN_RESOURCE:<azure_token>,ENVIRONMENT:azure');
await client.connect();
GCP Machine Authentication
The MongoClient
must be instantiated with authMechanism=MONGODB-OIDC
in the URI or in the client options. Additional required auth mechanism properties of TOKEN_RESOURCE
and ENVIRONMENT
are required. Example:
const client = new MongoClient('mongodb+srv://<host>:<port>/?authMechanism=MONGODB-OIDC&authMechanismProperties=TOKEN_RESOURCE:<gcp_token>,ENVIRONMENT:gcp');
await client.connect();
Callback Authentication
The user can provide a custom callback to the MongoClient
that returns a valid response with an access token. The callback is provided as an auth mechanism property an has the signature of:
const oidcCallBack = (params: OIDCCallbackParams): Promise<OIDCResponse> => {
// params.timeoutContext is an AbortSignal that will abort after 30 seconds for non-human and 5 minutes for human.
// params.version is the current OIDC API version.
// params.idpInfo is the IdP info returned from the server.
// params.username is the optional username.
// Make a call to get a token.
const token = ...;
return {
accessToken: token,
expiresInSeconds: 300,
refreshToken: token
};
}
const client = new MongoClient('mongodb+srv://<host>:<port>/?authMechanism=MONGODB-OIDC', {
authMechanismProperties: {
OIDC_CALLBACK: oidcCallback
}
});
await client.connect();
For callbacks that require human interaction, set the callback to the OIDC_HUMAN_CALLBACK
property:
const client = new MongoClient('mongodb+srv://<host>:<port>/?authMechanism=MONGODB-OIDC', {
authMechanismProperties: {
OIDC_HUMAN_CALLBACK: oidcCallback
}
});
await client.connect();
Fixed error when useBigInt64=true was set on Db or MongoClient
Fixed an issue where when setting useBigInt64
=true
on MongoClients or Dbs an internal function compareTopologyVersion
would throw an error when encountering a bigint value.
Features
Bug Fixes
Documentation
We invite you to try the mongodb
library immediately, and report any issues to the NODE project.