@@ -419,6 +419,52 @@ see the corresponding syntax.
419
419
:start-after: start-oidc-gcp-mongo-cred
420
420
:end-before: end-oidc-gcp-mongo-cred
421
421
422
+ .. _kotlin-sync-auth-kubernetes:
423
+
424
+ Kubernetes
425
+ ~~~~~~~~~~
426
+
427
+ If your application runs on a Kubernetes cluster, you can authenticate
428
+ to MongoDB by using the {+driver-short+}'s built-in Kubernetes support.
429
+
430
+ Select from the :guilabel:`Connection String` or
431
+ :guilabel:`MongoCredential` tabs to see the corresponding syntax.
432
+
433
+ .. tabs::
434
+
435
+ .. tab:: Connection String
436
+ :tabid: mongodb-kubernetes-connection-string
437
+
438
+ To specify Kubernetes OIDC as the authentication mechanism, set the following
439
+ options in your connection string:
440
+
441
+ - ``authMechanism``: Set to ``MONGODB-OIDC``.
442
+ - ``authMechanismProperties``: Set to ``ENVIRONMENT:k8s``.
443
+
444
+ Replace the ``<percent-encoded audience>`` placeholder in the
445
+ following code with the percent-encoded value of the audience server
446
+ parameter configured on your MongoDB deployment.
447
+
448
+ .. literalinclude:: /includes/security/enterprise-auth.kt
449
+ :language: kotlin
450
+ :dedent:
451
+ :start-after: start-oidc-k8s-connect-str
452
+ :end-before: end-oidc-k8s-connect-str
453
+
454
+ .. tab:: MongoCredential
455
+ :tabid: mongodb-kubernetes-mongo-credential
456
+
457
+ Replace the ``hostname`` and ``port`` with the network address and port
458
+ number of your MongoDB deployment. Also, replace the
459
+ ``<audience>`` placeholder with the value of the ``audience``
460
+ server parameter configured on your MongoDB deployment.
461
+
462
+ .. literalinclude:: /includes/security/enterprise-auth.kt
463
+ :language: kotlin
464
+ :dedent:
465
+ :start-after: start-oidc-k8s-mongo-cred
466
+ :end-before: end-oidc-k8s-mongo-cred
467
+
422
468
Custom Callback
423
469
~~~~~~~~~~~~~~~
424
470
0 commit comments