Skip to content

Commit 3e0e04e

Browse files
authored
DOCSP-44256 Add Kubernetes Support for OIDC (#950)
* DOCSP-44256 Add Kubernetes Support for OIDC * edits and remove monospace from titles * change depth to 2 * tech review fix for import
1 parent b12b677 commit 3e0e04e

File tree

1 file changed

+30
-7
lines changed

1 file changed

+30
-7
lines changed

source/fundamentals/authentication/enterprise-mechanisms.txt

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Enterprise Authentication Mechanisms
77
.. contents:: On this page
88
:local:
99
:backlinks: none
10-
:depth: 1
10+
:depth: 2
1111
:class: singlecol
1212

1313
.. facet::
@@ -21,8 +21,8 @@ In this guide, you can find sample code for connection to MongoDB with each
2121
authentication mechanism available in the MongoDB Enterprise Edition:
2222
``Kerberos (GSSAPI/SSPI)``, ``LDAP (PLAIN)``, and ``MONGODB-OIDC``.
2323

24-
``Kerberos (GSSAPI/SSPI)``
25-
--------------------------
24+
Kerberos (GSSAPI/SSPI)
25+
----------------------
2626

2727
.. note::
2828
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``.
102102
`GSSAPI RFC-4652 <https://tools.ietf.org/html/rfc4752>`_, the SASL
103103
mechanism.
104104

105-
``LDAP (PLAIN)``
106-
----------------
105+
LDAP (PLAIN)
106+
------------
107107

108108
The ``PLAIN`` authentication mechanism uses your username and password to
109109
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:
226226
+ "&authMechanismProperties=ENVIRONMENT:gcp,TOKEN_RESOURCE:<audience>";
227227
const client = new MongoClient(uri);
228228

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+
229252
Custom Callback
230253
~~~~~~~~~~~~~~~
231254

232255
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.
235258

236259
First, define a function that retrieves the access token to use for OIDC authentication.
237260
This function must have the following signature:

0 commit comments

Comments
 (0)