|
| 1 | +.. _c2c-authentication: |
| 2 | + |
| 3 | +================================================= |
| 4 | +Authentication Using Workload Identity Federation |
| 5 | +================================================= |
| 6 | + |
| 7 | +.. default-domain:: mongodb |
| 8 | + |
| 9 | +.. contents:: On this page |
| 10 | + :local: |
| 11 | + :backlinks: none |
| 12 | + :depth: 1 |
| 13 | + :class: twocols |
| 14 | + |
| 15 | +.. include:: /includes/mongosync-and-oidc.rst |
| 16 | + |
| 17 | +.. COMMENT Add the following link later |
| 18 | +.. COMMENT - :ref:`Workforce external provider </workforce-external-provider>` |
| 19 | + |
| 20 | +Examples |
| 21 | +-------- |
| 22 | + |
| 23 | +This section shows ``mongosync`` examples that use Workload Identity |
| 24 | +Federation. |
| 25 | + |
| 26 | +In the :ref:`connection string <connections-connection-options>`, set |
| 27 | +:urioption:`authMechanism` to ``MONGODB-OIDC`` and set |
| 28 | +:urioption:`authMechanismProperties` as needed: |
| 29 | + |
| 30 | +- For Microsoft Azure, set ``authMechanismProperties`` to |
| 31 | + ``ENVIRONMENT:azure`` |
| 32 | +- For Google Cloud Platform, set ``authMechanismProperties`` to |
| 33 | + ``ENVIRONMENT:gcp`` |
| 34 | + |
| 35 | +For details about connection string options, see |
| 36 | +:ref:`connection-string-auth-options`. |
| 37 | + |
| 38 | +Connect to MongoDB Clusters Using Microsoft Azure Instance Metadata Service |
| 39 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 40 | + |
| 41 | +The following ``mongosync`` example connects to MongoDB clusters using |
| 42 | +Microsoft Azure Instance Metadata Service (IMDS): |
| 43 | + |
| 44 | +.. code-block:: shell |
| 45 | + |
| 46 | + ./bin/mongosync \ |
| 47 | + --logPath /var/log/mongosync \ |
| 48 | + --cluster0 "mongodb://clusterOne01.fancyCorp.com:20020,clusterOne02.fancyCorp.com:20020,clusterOne03.fancyCorp.com:20020/?authMechanism=MONGODB-OIDC&authMechanismProperties=ENVIRONMENT:azure" \ |
| 49 | + --cluster1 "mongodb://clusterTwo01.fancyCorp.com:20020,clusterTwo02.fancyCorp.com:20020,clusterTwo03.fancyCorp.com:20020/?authMechanism=MONGODB-OIDC&authMechanismProperties=ENVIRONMENT:azure" |
| 50 | + |
| 51 | +.. _c2c-authentication-azure-managed-identities-example: |
| 52 | + |
| 53 | +Connect to MongoDB Clusters Using Microsoft Azure Managed Identities |
| 54 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 55 | + |
| 56 | +To connect to MongoDB clusters using Microsoft Azure Managed Identities |
| 57 | +and federated authentication, define these environment variables: |
| 58 | + |
| 59 | +.. list-table:: |
| 60 | + :header-rows: 1 |
| 61 | + :widths: 30 70 |
| 62 | + |
| 63 | + * - Environment Variable |
| 64 | + - Description |
| 65 | + |
| 66 | + * - ``AZURE_TENANT_ID`` |
| 67 | + - Azure tenant identifier. |
| 68 | + |
| 69 | + * - ``AZURE_APP_CLIENT_ID`` |
| 70 | + - Azure application client identifier. |
| 71 | + |
| 72 | + * - ``AZURE_CLIENT_ID`` |
| 73 | + - Azure client identifier. |
| 74 | + |
| 75 | + * - ``AZURE_FEDERATED_TOKEN_FILE`` |
| 76 | + - Azure federated token file path. |
| 77 | + |
| 78 | +For details about Azure and the variables, see the Microsoft Azure |
| 79 | +documentation. |
| 80 | + |
| 81 | +The following ``mongosync`` example defines the environment variables |
| 82 | +and connects to MongoDB clusters in Microsoft Azure: |
| 83 | + |
| 84 | +.. code-block:: shell |
| 85 | + |
| 86 | + AZURE_TENANT_ID=08206ab8-16a0-406d-85e4-2f15f5620fac \ |
| 87 | + AZURE_APP_CLIENT_ID=b6c835da-e536-425b-9405-64bc471e245b \ |
| 88 | + AZURE_CLIENT_ID=f176d4eb-7dcd-4f66-bccf-aaa316ee61fd \ |
| 89 | + AZURE_FEDERATED_TOKEN_FILE=/var/run/secrets/azure/tokens/azure-identity-token \ |
| 90 | + ./bin/mongosync \ |
| 91 | + --logPath /var/log/mongosync \ |
| 92 | + --cluster0 "mongodb://clusterOne01.fancyCorp.com:20020,clusterOne02.fancyCorp.com:20020,clusterOne03.fancyCorp.com:20020/?authMechanism=MONGODB-OIDC&authMechanismProperties=ENVIRONMENT:azure" \ |
| 93 | + --cluster1 "mongodb://clusterTwo01.fancyCorp.com:20020,clusterTwo02.fancyCorp.com:20020,clusterTwo03.fancyCorp.com:20020/?authMechanism=MONGODB-OIDC&authMechanismProperties=ENVIRONMENT:azure" |
| 94 | + |
| 95 | +Connect to MongoDB Clusters in Google Cloud Platform |
| 96 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 97 | + |
| 98 | +The following ``mongosync`` example connects to MongoDB clusters in |
| 99 | +Google Cloud Platform: |
| 100 | + |
| 101 | +.. code-block:: shell |
| 102 | + |
| 103 | + ./bin/mongosync \ |
| 104 | + --logPath /var/log/mongosync \ |
| 105 | + --cluster0 "mongodb://clusterOne01.fancyCorp.com:20020,clusterOne02.fancyCorp.com:20020,clusterOne03.fancyCorp.com:20020/?authMechanism=MONGODB-OIDC&authMechanismProperties=ENVIRONMENT:gcp" \ |
| 106 | + --cluster1 "mongodb://clusterTwo01.fancyCorp.com:20020,clusterTwo02.fancyCorp.com:20020,clusterTwo03.fancyCorp.com:20020/?authMechanism=MONGODB-OIDC&authMechanismProperties=ENVIRONMENT:gcp" |
| 107 | + |
| 108 | +No environment variables are required for Google Cloud Platform. |
| 109 | + |
| 110 | +Learn More |
| 111 | +---------- |
| 112 | + |
| 113 | +- :ref:`c2c-mongosync-behavior` |
| 114 | +- :ref:`c2c-connecting` |
| 115 | +- :ref:`c2c-states` |
| 116 | +- :ref:`c2c-api` |
| 117 | +- :ref:`c2c-cutover-process` |
0 commit comments