@@ -77,6 +77,12 @@ see the corresponding syntax:
77
77
78
78
.. tab:: Connection String
79
79
: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``.
80
86
81
87
Replace the ``<percent-encoded audience>`` placeholder in the
82
88
following code with the percent-encoded value of the audience server
@@ -134,6 +140,12 @@ see the corresponding syntax:
134
140
135
141
.. tab:: Connection String
136
142
: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``.
137
149
138
150
Replace the ``<percent-encoded audience>`` placeholder in the
139
151
following code with the percent-encoded value of the audience server
@@ -160,7 +172,7 @@ see the corresponding syntax:
160
172
161
173
.. code-block:: java
162
174
163
- MongoCredential credential = MongoCredential.createOidcCredential()
175
+ MongoCredential credential = MongoCredential.createOidcCredential(null )
164
176
.withMechanismProperty("ENVIRONMENT", "gcp")
165
177
.withMechanismProperty("TOKEN_RESOURCE", "<audience>");
166
178
@@ -171,6 +183,51 @@ see the corresponding syntax:
171
183
.credential(credential)
172
184
.build());
173
185
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
+
174
231
Custom Callback
175
232
~~~~~~~~~~~~~~~
176
233
0 commit comments