@@ -445,13 +445,11 @@ Select from the :guilabel:`Connection String` or
445
445
following code with the percent-encoded value of the audience server
446
446
parameter configured on your MongoDB deployment.
447
447
448
- .. code-block:: kotlin
449
-
450
- val connectionString = ConnectionString(
451
- "mongodb://<OIDC principal>@<hostname>:<port>/?" +
452
- "authMechanism=MONGODB-OIDC" +
453
- "&authMechanismProperties=ENVIRONMENT:k8s,TOKEN_RESOURCE:<percent-encoded audience>")
454
- val mongoClient = MongoClient.create(connectionString)
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
455
453
456
454
.. tab:: MongoCredential
457
455
:tabid: mongodb-kubernetes-mongo-credential
@@ -461,19 +459,11 @@ Select from the :guilabel:`Connection String` or
461
459
``<audience>`` placeholder with the value of the ``audience``
462
460
server parameter configured on your MongoDB deployment.
463
461
464
- .. code-block:: kotlin
465
-
466
- val credential = MongoCredential.createOidcCredential("<OIDC principal>")
467
- .withMechanismProperty("ENVIRONMENT", "k8s")
468
- .withMechanismProperty("TOKEN_RESOURCE", "<audience>")
469
-
470
- val mongoClient = MongoClient.create(
471
- MongoClientSettings.builder()
472
- .applyToClusterSettings { builder ->
473
- builder.hosts(listOf(ServerAddress("<hostname>", <port>)))
474
- }
475
- .credential(credential)
476
- .build())
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
477
467
478
468
Custom Callback
479
469
~~~~~~~~~~~~~~~
0 commit comments