Skip to content

DOCSP-42372: Change username and password placeholders #568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions source/connection-troubleshooting.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Connection Troubleshooting
.. code-block:: java
:copyable: false

String uri = "mongodb://<username>:<password>@<hostname>:<port>/?authSource=users&authMechanism=SCRAM-SHA-256";
String uri = "mongodb://<db_username>:<db_password>@<hostname>:<port>/?authSource=users&authMechanism=SCRAM-SHA-256";
MongoClient mongoClient = MongoClients.create(uri);

.. replacement:: credentials-provider-alternative-method-description
Expand All @@ -100,7 +100,7 @@ Connection Troubleshooting
.. code-block:: java
:copyable: false

MongoCredential credential = MongoCredential.createScramSha256Credential("<username>", "<authenticationDb>", "<password>");
MongoCredential credential = MongoCredential.createScramSha256Credential("<db_username>", "<authenticationDb>", "<dbpassword>");


.. replacement:: authentication-guide-reference
Expand All @@ -117,7 +117,7 @@ Connection Troubleshooting
.. code-block:: java
:copyable: false

MongoClient mongoClient = MongoClients.create("mongodb://<username>:<password>@<hostname>:<port>/?authSource=users");
MongoClient mongoClient = MongoClients.create("mongodb://<db_username>:<db_password>@<hostname>:<port>/?authSource=users");

.. replacement:: dns-resolution-anchor

Expand Down
6 changes: 3 additions & 3 deletions source/fundamentals/auth.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ mechanism:

.. code-block:: java

MongoClient mongoClient = MongoClients.create("mongodb://<username>:<password>@<hostname>:<port>/?authSource=<authenticationDb>");
MongoClient mongoClient = MongoClients.create("mongodb://<db_username>:<db_password>@<hostname>:<port>/?authSource=<authenticationDb>");

.. tab::
:tabid: MongoCredential
Expand Down Expand Up @@ -157,7 +157,7 @@ mechanism:

.. code-block:: java

MongoClient mongoClient = MongoClients.create("mongodb://<username>:<password>@<hostname>:<port>/?authSource=<authenticationDb>&authMechanism=SCRAM-SHA-256");
MongoClient mongoClient = MongoClients.create("mongodb://<db_username>:<db_password>@<hostname>:<port>/?authSource=<authenticationDb>&authMechanism=SCRAM-SHA-256");

.. tab::
:tabid: MongoCredential
Expand Down Expand Up @@ -215,7 +215,7 @@ mechanism:

.. code-block:: java

MongoClient mongoClient = MongoClients.create("mongodb://<username>:<password>@<hostname>:<port>/?authSource=<authenticationDb>&authMechanism=SCRAM-SHA-1");
MongoClient mongoClient = MongoClients.create("mongodb://<db_username>:<db_password>@<hostname>:<port>/?authSource=<authenticationDb>&authMechanism=SCRAM-SHA-1");

.. tab::
:tabid: MongoCredential
Expand Down
2 changes: 1 addition & 1 deletion source/fundamentals/connection/mongoclientsettings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ This example demonstrates specifying a ``ConnectionString``:
:emphasize-lines: 2,4

MongoClient mongoClient = MongoClients.create(
MongoClientSettings.builder().applyConnectionString(new ConnectionString("mongodb+srv://<username>:<password>@<hostname>:<port>/<auth db>?connectTimeoutMS=2000"))
MongoClientSettings.builder().applyConnectionString(new ConnectionString("mongodb+srv://<db_username>:<db_password>@<hostname>:<port>/<auth db>?connectTimeoutMS=2000"))
.applyToSocketSettings(builder ->
builder.connectTimeout(5L, SECONDS))
.build());
Expand Down
2 changes: 1 addition & 1 deletion source/fundamentals/connection/network-compression.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ connection string using ``ConnectionString`` or by calling the method in the

.. code-block:: java

ConnectionString connectionString = new ConnectionString("mongodb+srv://<user>:<password>@<cluster-url>/?compressors=snappy,zlib,zstd");
ConnectionString connectionString = new ConnectionString("mongodb+srv://<db_username>:<db_password>@<cluster-url>/?compressors=snappy,zlib,zstd");
MongoClient mongoClient = MongoClients.create(connectionString);

Specify compression algorithms using the following strings:
Expand Down
2 changes: 1 addition & 1 deletion source/fundamentals/connection/tls.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ using a method in the ``MongoClientSettings.Builder`` class.

.. code-block:: java

MongoClient mongoClient = MongoClients.create("mongodb+srv://<user>:<password>@<cluster-url>?tls=true");
MongoClient mongoClient = MongoClients.create("mongodb+srv://<db_username>:<db_password>@<cluster-url>?tls=true");

.. tab:: MongoClientSettings
:tabid: mongoclientsettings
Expand Down
12 changes: 6 additions & 6 deletions source/fundamentals/enterprise-auth.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ mechanism:

.. code-block:: java

MongoClient mongoClient = MongoClients.create("<username>@<hostname>:<port>/?authSource=$external&authMechanism=GSSAPI");
MongoClient mongoClient = MongoClients.create("<db_username>@<hostname>:<port>/?authSource=$external&authMechanism=GSSAPI");

.. tab::
:tabid: MongoCredential
Expand Down Expand Up @@ -151,7 +151,7 @@ You might need to specify one or more of the following additional

.. code-block:: java

MongoClient mongoClient = MongoClients.create("<username>@<hostname>:<port>/?authSource=$external&authMechanism=GSSAPI&authMechanismProperties=SERVICE_NAME:myService");
MongoClient mongoClient = MongoClients.create("<db_username>@<hostname>:<port>/?authSource=$external&authMechanism=GSSAPI&authMechanismProperties=SERVICE_NAME:myService");

.. tab::
:tabid: MongoCredential
Expand Down Expand Up @@ -277,7 +277,7 @@ mechanism:

.. code-block:: java

MongoClient mongoClient = MongoClients.create("<username>:<password>@<hostname>:<port>/?authSource=$external&authMechanism=PLAIN");
MongoClient mongoClient = MongoClients.create("<db_username>:<db_password>@<hostname>:<port>/?authSource=$external&authMechanism=PLAIN");

.. tab::
:tabid: MongoCredential
Expand Down Expand Up @@ -340,21 +340,21 @@ see the corresponding syntax.
.. code-block:: java

MongoClient mongoClient = MongoClients.create(
"mongodb://<username>@<hostname>:<port>/?" +
"mongodb://<db_username>@<hostname>:<port>/?" +
"?authMechanism=MONGODB-OIDC" +
"&authMechanismProperties=ENVIRONMENT:azure,TOKEN_RESOURCE:<percent-encoded audience>");

.. tab:: MongoCredential
:tabid: mongodb-azure-mongo-credential

Replace the ``<username>`` placeholder with the client ID or application ID of the
Replace the ``<db_username>`` placeholder with the client ID or application ID of the
Azure managed identity or enterprise application. Replace the ``<audience>``
placeholder with the value of the
``audience`` server parameter configured on your MongoDB deployment.

.. code-block:: java

MongoCredential credential = MongoCredential.createOidcCredential("<username>")
MongoCredential credential = MongoCredential.createOidcCredential("<db_username>")
.withMechanismProperty("ENVIRONMENT", "azure")
.withMechanismProperty("TOKEN_RESOURCE", "<audience>");

Expand Down
2 changes: 1 addition & 1 deletion source/fundamentals/indexes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -595,4 +595,4 @@ For prior versions of MongoDB, pass "*" as a parameter to your call to
For more information about the methods in this section, see the following API Documentation:

- `dropIndex() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoCollection.html#dropIndex(java.lang.String)>`__
- `dropIndexes() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoCollection.html#dropIndexes()>`__
- `dropIndexes() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoCollection.html#dropIndexes()>`__
2 changes: 1 addition & 1 deletion source/includes/faq/code-snippets/FaqExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static void main(String[] args) {
fromProviders(pojoCodecProvider));
// end myDateAsStringCodec

String uri = "mongodb+srv://<user>:<password>@<cluster-url>?retryWrites=true&w=majority";
String uri = "mongodb+srv://<db_username>:<db_password>@<cluster-url>?retryWrites=true&w=majority";

try (MongoClient mongoClient = MongoClients.create(uri)) {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.. code-block:: java

MongoCredential credential = MongoCredential.createCredential("<username>", "<authenticationDb>", "<password>");
MongoCredential credential = MongoCredential.createCredential("<db_username>", "<authenticationDb>", "<db_password>");

MongoClient mongoClient = MongoClients.create(
MongoClientSettings.builder()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.. code-block:: java

MongoCredential credential = MongoCredential.createGSSAPICredential(<username>);
MongoCredential credential = MongoCredential.createGSSAPICredential(<db_username>);
credential = credential.withMechanismProperty(MongoCredential.SERVICE_NAME_KEY, "myService");

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
loginContext.login();
Subject subject = loginContext.getSubject();

MongoCredential credential = MongoCredential.createGSSAPICredential(<username>);
MongoCredential credential = MongoCredential.createGSSAPICredential(<db_username>);
credential = credential.withMechanismProperty(MongoCredential.JAVA_SUBJECT_KEY, subject);

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/* all MongoClient instances sharing this instance of KerberosSubjectProvider
will share a Kerberos ticket cache */
String myLoginContext = "myContext";
MongoCredential credential = MongoCredential.createGSSAPICredential(<username>);
MongoCredential credential = MongoCredential.createGSSAPICredential(<db_username>);
/* login context defaults to "com.sun.security.jgss.krb5.initiate"
if unspecified in KerberosSubjectProvider */
credential = credential.withMechanismProperty(MongoCredential.JAVA_SUBJECT_PROVIDER_KEY,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.. code-block:: java

MongoCredential credential = MongoCredential.createGSSAPICredential(<username>);
MongoCredential credential = MongoCredential.createGSSAPICredential(<db_username>);

MongoClient mongoClient = MongoClients.create(
MongoClientSettings.builder()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.. code-block:: java

MongoCredential credential = MongoCredential.createPlainCredential(<username>, "$external", <password>);
MongoCredential credential = MongoCredential.createPlainCredential(<db_username>, "$external", <db_password>);

MongoClient mongoClient = MongoClients.create(
MongoClientSettings.builder()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.. code-block:: java

MongoCredential credential = MongoCredential.createScramSha1Credential("<username>", "<authenticationDb>", "<password>");
MongoCredential credential = MongoCredential.createScramSha1Credential("<db_username>", "<authenticationDb>", "<db_password>");

MongoClient mongoClient = MongoClients.create(
MongoClientSettings.builder()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.. code-block:: java

MongoCredential credential = MongoCredential.createScramSha256Credential("<username>", "<authenticationDb>", "<password>");
MongoCredential credential = MongoCredential.createScramSha256Credential("<db_username>", "<authenticationDb>", "<db_password>");

MongoClient mongoClient = MongoClients.create(
MongoClientSettings.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ private static void searchTextExample(MongoCollection<Document> coll) {

public static void main(String[] args) {
// Replace the uri string with your MongoDB deployment's connection string
String uri = "mongodb+srv://<user>:<password>@<cluster-url>?retryWrites=true&w=majority";
String uri = "mongodb+srv://<db_username>:<db_password>@<cluster-url>?retryWrites=true&w=majority";
try (MongoClient mongoClient = MongoClients.create(uri)) {

MongoDatabase database = mongoClient.getDatabase("movies");
Expand Down
2 changes: 1 addition & 1 deletion source/quick-start.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Create a new file ``QuickStartPojoExample.java`` in the same package
directory as your ``Movie`` file in your project. Use the following sample
code to run a query on your sample dataset in MongoDB Atlas, replacing the
value of the ``uri`` variable with your MongoDB Atlas connection string.
Ensure you replace the "<password>" section of the connection string with
Ensure you replace the "<db_password>" section of the connection string with
the password you created for your user that has **atlasAdmin** permissions:

.. literalinclude:: /includes/quick-start/code-snippets/QuickStartPojoExample.java
Expand Down
2 changes: 1 addition & 1 deletion source/usage-examples.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ to learn how to allow connections to your instance of Atlas and to find the
:manual:`connection string </reference/connection-string/>` you use to replace the
``uri`` variable in usage examples. If your instance uses
:manual:`SCRAM authentication </core/security-scram/>`, you can replace
``<user>`` with your username, ``<password>`` with your password, and
``<db_username>`` with your database username, ``<db_password>`` with your database password, and
``<cluster-url>`` with the IP address or URL of your instance.

For more information about connecting to your MongoDB instance, see our
Expand Down
Loading