Skip to content

[Backport v5.2] [Backport v5.3] DOCSP-48713 Update non-MongoDB credentials #680

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 1 commit into from
Apr 25, 2025
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.. code-block:: java

MongoCredential credential = MongoCredential.createGSSAPICredential(<db_username>);
MongoCredential credential = MongoCredential.createGSSAPICredential(<principal_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(<db_username>);
MongoCredential credential = MongoCredential.createGSSAPICredential(<principal_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(<db_username>);
MongoCredential credential = MongoCredential.createGSSAPICredential(<principal_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(<db_username>);
MongoCredential credential = MongoCredential.createGSSAPICredential(<principal_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(<db_username>, "$external", <db_password>);
MongoCredential credential = MongoCredential.createPlainCredential(<username>, "$external", <db_password>);

MongoClient mongoClient = MongoClients.create(
MongoClientSettings.builder()
Expand Down
8 changes: 4 additions & 4 deletions source/security/enterprise-auth.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ principal name.
The following code snippets show how to specify the authentication mechanism,
using the following placeholders:

- ``username``: your URL-encoded principal name, such as ``"username%40REALM.ME"``
- ``principal_username``: your URL-encoded principal name, such as ``"username%40REALM.ME"``
- ``hostname``: network address of your MongoDB deployment that your
client can access
- ``port``: port number of your MongoDB deployment
Expand Down Expand Up @@ -91,7 +91,7 @@ mechanism:

.. code-block:: java

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

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

.. code-block:: java

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

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

.. code-block:: java

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

.. tab::
:tabid: MongoCredential
Expand Down