@@ -7,7 +7,7 @@ Enterprise Authentication Mechanisms
7
7
.. contents:: On this page
8
8
:local:
9
9
:backlinks: none
10
- :depth: 1
10
+ :depth: 2
11
11
:class: singlecol
12
12
13
13
.. facet::
@@ -21,8 +21,8 @@ In this guide, you can find sample code for connection to MongoDB with each
21
21
authentication mechanism available in the MongoDB Enterprise Edition:
22
22
``Kerberos (GSSAPI/SSPI)``, ``LDAP (PLAIN)``, and ``MONGODB-OIDC``.
23
23
24
- `` Kerberos (GSSAPI/SSPI)``
25
- --------------------------
24
+ Kerberos (GSSAPI/SSPI)
25
+ ----------------------
26
26
27
27
.. note::
28
28
The Node.js driver supports Kerberos on UNIX using the MIT Kerberos library
@@ -102,8 +102,8 @@ The following code sample authenticates to Kerberos for UNIX using ``GSSAPI``.
102
102
`GSSAPI RFC-4652 <https://tools.ietf.org/html/rfc4752>`_, the SASL
103
103
mechanism.
104
104
105
- `` LDAP (PLAIN)``
106
- ----------------
105
+ LDAP (PLAIN)
106
+ ------------
107
107
108
108
The ``PLAIN`` authentication mechanism uses your username and password to
109
109
authenticate to a Lightweight Directory Access Protocol (LDAP) server.
@@ -226,12 +226,35 @@ The following code example shows how to set the preceding connection options:
226
226
+ "&authMechanismProperties=ENVIRONMENT:gcp,TOKEN_RESOURCE:<audience>";
227
227
const client = new MongoClient(uri);
228
228
229
+ Kubernetes
230
+ ~~~~~~~~~~
231
+
232
+ If your application runs on a Kubernetes cluster, you can authenticate to MongoDB by using
233
+ the {+driver-short+}'s built-in Kubernetes support.
234
+
235
+ To specify Kubernetes OIDC as the authentication mechanism, set the following
236
+ options in your connection string:
237
+
238
+ - ``authMechanism``: Set to ``MONGODB-OIDC``.
239
+ - ``authMechanismProperties``: Set to ``ENVIRONMENT:k8s``.
240
+
241
+ The following code example shows how to set the preceding connection options:
242
+
243
+ .. code-block:: js
244
+ :emphasize-lines: 3-4
245
+
246
+ import { MongoClient } from "mongodb";
247
+
248
+ const uri = "mongodb://<hostname>:<port>/?authMechanism=MONGODB-OIDC"
249
+ + "&authMechanismProperties=ENVIRONMENT:k8s";
250
+ const client = new MongoClient(uri);
251
+
229
252
Custom Callback
230
253
~~~~~~~~~~~~~~~
231
254
232
255
The {+driver-short+} doesn't offer built-in support for all platforms, including
233
- Azure Functions and Azure Kubernetes Service (AKS). Instead, you
234
- must define a custom callback to use OIDC to authenticate from these platforms.
256
+ Azure Functions. Instead, you must define a custom callback to use OIDC to
257
+ authenticate from these platforms.
235
258
236
259
First, define a function that retrieves the access token to use for OIDC authentication.
237
260
This function must have the following signature:
0 commit comments