1
- .. _node-authentication-mechanisms:
2
-
3
1
=========================
4
2
Authentication Mechanisms
5
3
=========================
@@ -124,7 +122,7 @@ in the following sample code.
124
122
SCRAM </release-notes/3.0-scram/>`, any ``MONGODB-CR`` user
125
123
authentication requests fail.
126
124
127
- .. _mongodb-aws:
125
+ .. _mongodb-aws:
128
126
129
127
``MONGODB-AWS``
130
128
---------------
@@ -144,7 +142,7 @@ user. If you do not already have the `AWS signature library
144
142
npm install aws4
145
143
146
144
To connect to a MongoDB instance with ``MONGODB-AWS`` authentication
147
- enabled, specify the ``MONGODB-AWS`` authentication mechanism.
145
+ enabled, specify the ``MONGODB-AWS`` authentication mechanism.
148
146
149
147
The driver checks for your credentials in the following sources in order:
150
148
@@ -163,19 +161,19 @@ The driver checks for your credentials in the following sources in order:
163
161
add your ``AWS_ACCESS_KEY_ID`` and ``AWS_SECRET_ACCESS_KEY``
164
162
credentials to your environment variables. If your AWS
165
163
login requires an ``AWS_SESSION_TOKEN``, add it to your
166
- environment variables as well.
164
+ environment variables as well.
167
165
168
166
The following code shows an example of specifying the ``MONGODB-AWS``
169
167
authentication mechanism with environment variables:
170
168
171
169
.. note::
172
-
170
+
173
171
You don't need to specify these credentials in your connection URI
174
172
because the driver automatically retrieves them when you attempt
175
173
to connect.
176
174
177
175
.. literalinclude:: /code-snippets/authentication/aws-env-variable.js
178
- :language: javascript
176
+ :language: javascript
179
177
180
178
.. tab:: Connection String
181
179
:tabid: connection string
@@ -189,13 +187,13 @@ The driver checks for your credentials in the following sources in order:
189
187
authentication mechanism and credentials with a connection string:
190
188
191
189
.. important::
192
-
190
+
193
191
Always **URI encode** the username and certificate file path using the
194
192
``encodeURIComponent`` method to ensure they are correctly parsed.
195
193
196
194
.. literalinclude:: /code-snippets/authentication/aws.js
197
- :language: javascript
198
-
195
+ :language: javascript
196
+
199
197
``X.509``
200
198
---------
201
199
0 commit comments