You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: source/fundamentals/authentication.txt
+176-6Lines changed: 176 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -23,6 +23,7 @@ of {+mongo-community+}:
23
23
24
24
- :ref:`csharp-scram-sha-256`
25
25
- :ref:`csharp-scram-sha-1`
26
+
- :ref:`csharp-mongodb-aws`
26
27
- :ref:`csharp-x509`
27
28
28
29
To authenticate using ``GSSAPI/Kerberos`` or ``LDAP``, see the
@@ -46,14 +47,14 @@ MongoDB using either of the following methods:
46
47
Mechanisms
47
48
----------
48
49
49
-
The following examples specify authentication mechanisms using the following
50
+
The following examples contain code examples that use the following
50
51
placeholders:
51
52
52
-
- ``<username>``: Your MongoDB username.
53
-
- ``<password>``: Your MongoDB user's password.
54
-
- ``<hostname>``: The network address of your MongoDB server, accessible by your client.
55
-
- ``<port>``: The port number of your MongoDB server.
56
-
- ``<authenticationDb>``: The MongoDB database that contains your user's authentication
53
+
- ``<username>`` - MongoDB username.
54
+
- ``<password>`` - MongoDB user's password.
55
+
- ``<hostname>`` - network address of the MongoDB server, accessible by your client.
56
+
- ``<port>`` - port number of the MongoDB server.
57
+
- ``<authenticationDb>`` - MongoDB database that contains the user's authentication
57
58
data. If you omit this parameter, the driver uses the default value ``admin``.
58
59
59
60
.. _csharp-authentication-default:
@@ -142,6 +143,175 @@ string as follow:
142
143
143
144
To learn more on specifying the default mechanism, see :ref:`csharp-authentication-default`.
144
145
146
+
.. _csharp-mongodb-aws:
147
+
148
+
MONGODB-AWS
149
+
~~~~~~~~~~~
150
+
151
+
.. note::
152
+
153
+
The ``MONGODB-AWS`` authentication mechanism is available only for
154
+
MongoDB deployments on MongoDB Atlas.
155
+
156
+
The ``MONGODB-AWS`` authentication mechanism uses your Amazon Web Services
157
+
Identity and Access Management (AWS IAM) credentials to authenticate your
158
+
user. You can either specify your credentials explicitly
159
+
or instruct the driver to retrieve them automatically from an external source.
160
+
161
+
The following sections contain code examples that use the following placeholders:
162
+
163
+
- ``<awsKeyId>`` - value of the AWS access key ID
164
+
- ``<awsSecretKey>`` - value of the AWS secret access key
165
+
- ``<awsSessionToken>`` - value of the AWS session token
166
+
167
+
.. tip::
168
+
169
+
To learn more about configuring MongoDB Atlas with AWS IAM, see the
170
+
:atlas:`Set Up Passwordless Authentication with AWS IAM Roles </security/passwordless-authentication/#set-up-passwordless-authentication-with-aws-iam-roles>` guide.
171
+
172
+
Specify Your AWS IAM Credentials
173
+
++++++++++++++++++++++++++++++++
174
+
175
+
You can supply your AWS IAM credentials on a ``MongoClientSettings`` object either by
176
+
using a ``MongoCredential`` object or as part of the connection string. Select the
177
+
:guilabel:`Connection String` or :guilabel:`MongoCredential` tab to
178
+
see the corresponding syntax for specifying your credentials:
var connectionString = "mongodb+srv://<awsKeyId>:<awsSecretKey>@<hostname>[:<port>]?authSource=$external&authMechanism=MONGODB-AWS";
188
+
var mongoClientSettings = MongoClientSettings.FromConnectionString(connectionString);
189
+
var client = new MongoClient(mongoClientSettings);
190
+
191
+
If you're using an AWS session token, include the ``authMechanismProperties``
192
+
parameter in the connection string as shown below:
193
+
194
+
.. code-block:: csharp
195
+
196
+
var connectionString = "mongodb+srv://<awsKeyId>:<awsSecretKey>@<hostname>[:<port>]?authSource=$external&authMechanism=MONGODB-AWS&authMechanismProperties=AWS_SESSION_TOKEN:<awsSessionToken>";
0 commit comments