@@ -79,8 +79,6 @@ using a ``MongoCredential`` object or as part of the connection string. Select t
79
79
:guilabel:`Connection String` or :guilabel:`MongoCredential` tab to
80
80
see the corresponding syntax.
81
81
82
- .. include:: /includes/comma-auth-options.rst
83
-
84
82
.. tabs::
85
83
86
84
.. tab:: Connection String
@@ -127,8 +125,6 @@ using a ``MongoCredential`` object or as part of the connection string. Select t
127
125
:guilabel:`Connection String` or :guilabel:`MongoCredential` tab to
128
126
see the corresponding syntax.
129
127
130
- .. include:: /includes/comma-auth-options.rst
131
-
132
128
.. tabs::
133
129
134
130
.. tab:: Connection String
@@ -159,11 +155,51 @@ see the corresponding syntax.
159
155
.WithMechanismProperty("TOKEN_RESOURCE", "<audience>");
160
156
var client = new MongoClient(mongoClientSettings);
161
157
158
+ Kubernetes
159
+ ~~~~~~~~~~
160
+
161
+ If your application runs on a Kubernetes cluster, you can authenticate to MongoDB by using
162
+ the {+driver-short+}'s built-in Kubernetes support.
163
+
164
+ You can specify Kubernetes OIDC authentication on a ``MongoClientSettings`` object either by
165
+ using a ``MongoCredential`` object or as part of the connection string. Select the
166
+ :guilabel:`Connection String` or :guilabel:`MongoCredential` tab to
167
+ see the corresponding syntax.
168
+
169
+ .. tabs::
170
+
171
+ .. tab:: Connection String
172
+ :tabid: oidc-kubernetes-connection-string
173
+
174
+ The following code example shows how to specify Kubernetes OIDC authentication as
175
+ part of the connection string:
176
+
177
+ .. code-block:: csharp
178
+
179
+ var connectionString = "mongodb://<hostname>[:<port>]/?authMechanism=MONGODB-OIDC" +
180
+ "&authMechanismProperties=ENVIRONMENT:k8s";
181
+ var mongoClientSettings = MongoClientSettings.FromConnectionString(connectionString);
182
+ var client = new MongoClient(mongoClientSettings);
183
+
184
+ .. tab:: MongoCredential
185
+ :tabid: oidc-kubernetes-mongo-credential
186
+
187
+ The following code example shows how to specify Kubernetes OIDC authentication by using
188
+ a ``MongoCredential`` object:
189
+
190
+ .. code-block:: csharp
191
+
192
+ var mongoClientSettings = MongoClientSettings.FromConnectionString(
193
+ "mongodb://<hostname>[:<port>]");
194
+ mongoClientSettings.Credential = MongoCredential
195
+ .CreateOidcCredential("k8s")
196
+ var client = new MongoClient(mongoClientSettings);
197
+
162
198
Custom Callback
163
199
~~~~~~~~~~~~~~~
164
200
165
201
The {+driver-short+} doesn't offer built-in support for all platforms, including
166
- Azure Functions and Azure Kubernetes Service (AKS) . Instead, you
202
+ Azure Functions. Instead, you
167
203
must define a custom callback to use OIDC to authenticate from these platforms.
168
204
169
205
First, define a class that implements the ``IOidcCallback`` interface. This interface
0 commit comments