Skip to content

Commit 51473b1

Browse files
authored
DOCSP-42374: go username/pass placeholders (mongodb#378)
1 parent c26a559 commit 51473b1

File tree

5 files changed

+22
-23
lines changed

5 files changed

+22
-23
lines changed

source/connection-troubleshooting.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ To learn more about authentication, see the
139139
Verify User Is in Authentication Database
140140
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
141141

142-
To successfully authenticate a connection by using a username and password,
142+
To successfully authenticate a connection by using a database username and password,
143143
the username must be defined in the authentication database. The default
144144
authentication database is the ``admin`` database. To use a different database
145145
for authentication, specify the ``authSource`` in the connection string. The
@@ -149,7 +149,7 @@ database:
149149
.. code-block:: go
150150
:copyable: true
151151

152-
uri := "mongodb://<username>:<password>@<hostname>:<port>/?authSource=users"
152+
uri := "mongodb://<db_username>:<db_password>@<hostname>:<port>/?authSource=users"
153153
client, err := mongo.Connect(options.Client().ApplyURI(uri))
154154

155155
Error Sending Message
@@ -237,7 +237,7 @@ connection string option:
237237

238238
.. code-block:: go
239239

240-
uri := "mongodb://<username>:<password>@<hostname>:27017/?timeoutMS=5000"
240+
uri := "mongodb://<db_username>:<db_password>@<hostname>:27017/?timeoutMS=5000"
241241
client, err := mongo.Connect(options.Client().ApplyURI(uri))
242242

243243
Check the Number of Connections

source/fundamentals/auth.txt

+9-9
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ Example Conventions
5353

5454
Each authentication mechanism contains the following placeholders:
5555

56-
* ``username`` - Your MongoDB username
57-
* ``password`` - Your MongoDB user's password
56+
* ``db_username`` - Your MongoDB database username
57+
* ``db_password`` - Your MongoDB database user's password
5858
* ``hostname`` - Your MongoDB servers network address, accessible by
5959
your client
6060
* ``port`` - Your MongoDB servers port number
@@ -94,8 +94,8 @@ To specify the default authentication mechanism, omit the
9494

9595
credential := options.Credential{
9696
AuthSource: "<authenticationDb>",
97-
Username: "<username>",
98-
Password: "<password>",
97+
Username: "<db_username>",
98+
Password: "<db_password>",
9999
}
100100
clientOpts := options.Client().ApplyURI("mongodb://<hostname>:<port>").
101101
SetAuth(credential)
@@ -117,7 +117,7 @@ see the :manual:`SCRAM </core/security-scram/>` section of the server manual.
117117
in MongoDB 4.0.
118118

119119
``SCRAM-SHA-256`` is a salted challenge-response authentication mechanism
120-
(SCRAM) that uses your username and password, encrypted with the ``SHA-256``
120+
(SCRAM) that uses your database username and password, encrypted with the ``SHA-256``
121121
algorithm, to authenticate your user.
122122

123123
To specify the ``SCRAM-SHA-256`` authentication mechanism, assign the
@@ -129,8 +129,8 @@ To specify the ``SCRAM-SHA-256`` authentication mechanism, assign the
129129
credential := options.Credential{
130130
AuthMechanism: "SCRAM-SHA-256",
131131
AuthSource: "<authenticationDb>",
132-
Username: "<username>",
133-
Password: "<password>",
132+
Username: "<db_username>",
133+
Password: "<db_password>",
134134
}
135135
clientOpts := options.Client().ApplyURI("mongodb://<hostname>:<port>").
136136
SetAuth(credential)
@@ -161,8 +161,8 @@ To specify the ``SCRAM-SHA-1`` authentication mechanism, assign the
161161
credential := options.Credential{
162162
AuthMechanism: "SCRAM-SHA-1",
163163
AuthSource: "<authenticationDb>",
164-
Username: "<username>",
165-
Password: "<password>",
164+
Username: "<db_username>",
165+
Password: "<db_password>",
166166
}
167167
clientOpts := options.Client().ApplyURI("mongodb://<hostname>:<port>").
168168
SetAuth(credential)

source/fundamentals/connections/connection-guide.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ You can also use the :manual:`DNS Seed List Connection Format
5454
want more flexibility of deployment and the ability to change the
5555
servers in rotation without reconfiguring clients.
5656

57-
The next part of the connection string contains your username and, if
57+
The next part of the connection string contains your database username and, if
5858
you are using password-based authentication, your password. Replace the value of
59-
``user`` with your username and ``pass`` with your password. If you are using an
59+
``user`` with your database username and ``pass`` with your password. If you are using an
6060
authentication mechanism that does not require a username and password, omit
6161
this part of the connection URI.
6262

source/fundamentals/enterprise-auth.txt

+7-7
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Example
7171
This example specifies the authentication mechanism using the following
7272
placeholders:
7373

74-
- ``username``: Your Kerberos principal. A sample username is ``[email protected]``.
74+
- ``Kerberos principal``: Your Kerberos principal. A sample username is ``[email protected]``.
7575
- ``password``: Your Kerberos user's password. You can also store your
7676
password in a ``keytab`` file to avoid exposing your
7777
password in your code.
@@ -85,7 +85,7 @@ preferences:
8585

8686
credential := options.Credential{
8787
AuthMechanism: "GSSAPI",
88-
Username: "<username>",
88+
Username: "<Kerberos principal>",
8989
Password: "<password>",
9090
PasswordSet: true,
9191
}
@@ -116,7 +116,7 @@ MongoDB server:
116116

117117
.. code-block:: go
118118

119-
uri := "mongodb://<username>:<password>@<hostname>/?authMechanism=GSSAPI"
119+
uri := "mongodb://<Kerberos principal>:<password>@<hostname>/?authMechanism=GSSAPI"
120120

121121
Set Custom ``SERVICE_NAME`` and ``SERVICE_REALM`` Fields
122122
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -132,7 +132,7 @@ for the ``SERVICE_NAME`` and ``SERVICE_REALM`` fields when defining a
132132

133133
credential := options.Credential{
134134
AuthMechanism: "GSSAPI",
135-
Username: "<username>",
135+
Username: "<Kerberos principal>",
136136
Password: "<password>",
137137
AuthMechanismProperties: map[string]string{
138138
"SERVICE_REALM": "<Kerberos service realm>",
@@ -162,7 +162,7 @@ Example
162162
This example specifies the authentication mechanism using the following
163163
placeholders:
164164

165-
- ``username``: Your LDAP username
165+
- ``LDAP username``: Your LDAP username
166166
- ``password``: Your LDAP password
167167
- ``connection uri``: Your connection string URI
168168

@@ -174,7 +174,7 @@ preferences:
174174

175175
credential := options.Credential{
176176
AuthMechanism: "PLAIN",
177-
Username: "<username>",
177+
Username: "<LDAP username>",
178178
Password: "<password>",
179179
}
180180

@@ -189,7 +189,7 @@ address of your MongoDB server:
189189

190190
.. code-block:: go
191191

192-
uri := "mongodb://<username>:<password>@<hostname>/?authMechanism=PLAIN"
192+
uri := "mongodb://<LDAP username>:<password>@<hostname>/?authMechanism=PLAIN"
193193

194194
.. note::
195195

source/usage-examples.txt

+1-2
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ your connection string.
7878

7979
.. _golang-usage-examples-env-variable:
8080

81-
8281
You can use `GoDotEnv <https://github.com/joho/godotenv>`__ to define
8382
your environment variable.
8483

@@ -89,7 +88,7 @@ deployment's connection string. To learn more, see the
8988

9089
.. code-block::
9190

92-
MONGODB_URI=mongodb+srv://<user>:<password>@<cluster-url>?retryWrites=true&w=majority
91+
MONGODB_URI=mongodb+srv://<db_username>:<db_password>@<cluster-url>?retryWrites=true&w=majority
9392

9493
Examples
9594
--------

0 commit comments

Comments
 (0)