@@ -33,7 +33,7 @@ the driver attempts to authenticate using ``MONGODB-CR``.
33
33
34
34
You can specify this authentication mechanism by setting the ``authMechanism``
35
35
parameter to ``DEFAULT`` in the
36
- :manual:`URI ConnectionString </reference/connection-string/>`, or by omitting
36
+ :manual:`connection string </reference/connection-string/>`, or by omitting
37
37
the parameter since it is the default value. Also include your username and
38
38
password as shown in the code below.
39
39
@@ -63,9 +63,13 @@ algorithm to authenticate your user.
63
63
64
64
You can specify this authentication mechanism by setting the ``authMechanism``
65
65
to the value ``SCRAM-SHA-256`` in the
66
- :manual:`URI ConnectionString </ reference/connection-string/>` as shown in the
66
+ :manual:`connection string < reference/connection-string/>` as shown in the
67
67
following sample code.
68
68
69
+ .. important::
70
+ Always **URI encode** the username and password using the
71
+ ``encodeURIComponent`` method to ensure they are correctly parsed.
72
+
69
73
.. literalinclude:: /code-snippets/authentication/sha256.js
70
74
:language: javascript
71
75
:dedent: 4
@@ -83,9 +87,13 @@ your user.
83
87
84
88
You can specify this authentication mechanism by setting the ``authMechanism``
85
89
parameter to the value ``SCRAM-SHA-1`` in the
86
- :manual:`URI ConnectionString </reference/connection-string/>` as shown
90
+ :manual:`connection string </reference/connection-string/>` as shown
87
91
in the following sample code.
88
92
93
+ .. important::
94
+ Always **URI encode** the username and password using the
95
+ ``encodeURIComponent`` method to ensure they are correctly parsed.
96
+
89
97
.. literalinclude:: /code-snippets/authentication/sha1.js
90
98
:language: javascript
91
99
:dedent: 4
@@ -101,9 +109,13 @@ username and password to authenticate your user.
101
109
102
110
You can specify this option by setting the ``authMechanism`` parameter to value
103
111
``MONGODB-CR`` in the
104
- :manual:`URI ConnectionString </reference/connection-string/>` as shown
112
+ :manual:`connection string </reference/connection-string/>` as shown
105
113
in the following sample code.
106
114
115
+ .. important::
116
+ Always **URI encode** the username and password using the
117
+ ``encodeURIComponent`` method to ensure they are correctly parsed.
118
+
107
119
.. literalinclude:: /code-snippets/authentication/cr.js
108
120
:language: javascript
109
121
:dedent: 4
@@ -129,14 +141,18 @@ the X.509 certificate, see the MongoDB manual :manual:`X.509 tutorial
129
141
130
142
You can specify this authentication mechanism by setting the following
131
143
parameters of your
132
- :manual:`URI ConnectionString </reference/connection-string/>`:
144
+ :manual:`connection string </reference/connection-string/>`:
133
145
134
146
- Set the ``authMechanism`` parameter to the value ``MONGODB-X509``
135
147
- Set the ``tls`` parameter to the value ``true``
136
148
137
149
Pass the location of your client certificate file as the value of
138
150
``tlsCertificateKeyFile`` as a parameter of the connection URI.
139
151
152
+ .. important::
153
+ Always **URI encode** the username and certificate file path using the
154
+ ``encodeURIComponent`` method to ensure they are correctly parsed.
155
+
140
156
.. literalinclude:: /code-snippets/authentication/x509.js
141
157
:language: javascript
142
158
:dedent: 4
0 commit comments