@@ -77,6 +77,12 @@ see the corresponding syntax:
7777
7878 .. tab:: Connection String
7979 :tabid: mongodb-azure-imds-connection-string
80+
81+ To specify Azure IMDS OIDC as the authentication mechanism, set the following
82+ options in your connection string:
83+
84+ - ``authMechanism``: Set to ``MONGODB-OIDC``.
85+ - ``authMechanismProperties``: Set to ``ENVIRONMENT:azure``.
8086
8187 Replace the ``<percent-encoded audience>`` placeholder in the
8288 following code with the percent-encoded value of the audience server
@@ -134,6 +140,12 @@ see the corresponding syntax:
134140
135141 .. tab:: Connection String
136142 :tabid: mongodb-gcp-imds-connection-string
143+
144+ To specify GCP IMDS OIDC as the authentication mechanism, set the following
145+ options in your connection string:
146+
147+ - ``authMechanism``: Set to ``MONGODB-OIDC``.
148+ - ``authMechanismProperties``: Set to ``ENVIRONMENT:gcp``.
137149
138150 Replace the ``<percent-encoded audience>`` placeholder in the
139151 following code with the percent-encoded value of the audience server
@@ -160,7 +172,7 @@ see the corresponding syntax:
160172
161173 .. code-block:: java
162174
163- MongoCredential credential = MongoCredential.createOidcCredential()
175+ MongoCredential credential = MongoCredential.createOidcCredential(null )
164176 .withMechanismProperty("ENVIRONMENT", "gcp")
165177 .withMechanismProperty("TOKEN_RESOURCE", "<audience>");
166178
@@ -171,6 +183,51 @@ see the corresponding syntax:
171183 .credential(credential)
172184 .build());
173185
186+ Kubernetes
187+ ~~~~~~~~~~
188+
189+ If your application runs on a Kubernetes cluster, you can authenticate to MongoDB
190+ by using the {+driver-short+}'s built-in Kubernetes support.
191+
192+ Select from the :guilabel:`Connection String` or :guilabel:`MongoCredential` tabs to
193+ see the corresponding syntax.
194+
195+ .. tabs::
196+
197+ .. tab:: Connection String
198+ :tabid: mongodb-kubernetes-connection-string
199+
200+ To specify Kubernetes OIDC as the authentication mechanism, set the following
201+ options in your connection string:
202+
203+ - ``authMechanism``: Set to ``MONGODB-OIDC``.
204+ - ``authMechanismProperties``: Set to ``ENVIRONMENT:k8s``.
205+
206+ .. code-block:: java
207+
208+ MongoClient mongoClient = MongoClients.create(
209+ "mongodb://<hostname>:<port>/" +
210+ "?authMechanism=MONGODB-OIDC" +
211+ "&authMechanismProperties=ENVIRONMENT:k8s");
212+
213+ .. tab:: MongoCredential
214+ :tabid: mongodb-kubernetes-mongo-credential
215+
216+ Replace the ``hostname`` and ``port`` with the network address and port
217+ number of your MongoDB deployment.
218+
219+ .. code-block:: java
220+
221+ MongoCredential credential = MongoCredential.createOidcCredential(null)
222+ .withMechanismProperty("ENVIRONMENT", "k8s");
223+
224+ MongoClient mongoClient = MongoClients.create(
225+ MongoClientSettings.builder()
226+ .applyToClusterSettings(builder ->
227+ builder.hosts(Arrays.asList(new ServerAddress("<hostname>", <port>))))
228+ .credential(credential)
229+ .build());
230+
174231Custom Callback
175232~~~~~~~~~~~~~~~
176233
0 commit comments