Skip to content

Commit 26fdc89

Browse files
author
Chris Cho
authored
DOCSP-8454: Migrate TLS Options to docs-node (#43)
* DOCSP-8454: add table for TLS options, add connection page
1 parent 1b73442 commit 26fdc89

File tree

14 files changed

+518
-363
lines changed

14 files changed

+518
-363
lines changed

snooty.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name = "node"
2-
toc_landing_pages = ["/crud", "/crud/read-operations", "/crud/write-operations"]
2+
#toc_landing_pages = ["/crud", "/crud/read-operations", "/crud/write-operations"]
33

44
[constants]
55
version = 4.0
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// ignored first line
2+
const { MongoClient } = require("mongodb");
3+
const fs = require("fs");
4+
5+
// specify the placeholder values for your environment in the following lines
6+
const username = encodeURIComponent("<username>");
7+
const password = encodeURIComponent("<password>");
8+
const clusterUrl = "<MongoDB cluster url>";
9+
10+
11+
// Replace the following with your MongoDB deployment's connection
12+
// string.
13+
const uri =
14+
`mongodb+srv://${username}:${password}@${clusterUrl}/?authMechanism=${authMechanism}&tls=true&tlsCertificateKeyFile=${clientPEMFile}`;
15+
16+
// Create a new MongoClient
17+
const client = new MongoClient(uri);
18+
19+
// Function to connect to the server
20+
async function run() {
21+
try {
22+
// Connect the client to the server
23+
await client.connect();
24+
25+
// Establish and verify connection
26+
await client.db("admin").command({ ping: 1 });
27+
console.log("Connected successfully to server");
28+
} finally {
29+
// Ensures that the client will close when you finish/error
30+
await client.close();
31+
}
32+
}
33+
run().catch(console.dir);
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// ignored first line
2+
const { MongoClient } = require("mongodb");
3+
4+
// specify the placeholder values for your environment in the following lines
5+
const username = encodeURIComponent("<username>");
6+
const password = encodeURIComponent("<password>");
7+
const clusterUrl = "<MongoDB cluster url>";
8+
9+
const authMechanism = "DEFAULT";
10+
11+
// Replace the following with your MongoDB deployment's connection
12+
// string.
13+
const uri =
14+
`mongodb+srv://${username}:${password}@${clusterUrl}/?authMechanism=${authMechanism}`;
15+
16+
// Create a new MongoClient
17+
const client = new MongoClient(uri);
18+
19+
// Function to connect to the server
20+
async function run() {
21+
try {
22+
// Connect the client to the server
23+
await client.connect();
24+
25+
// Establish and verify connection
26+
await client.db("admin").command({ ping: 1 });
27+
console.log("Connected successfully to server");
28+
} finally {
29+
// Ensures that the client will close when you finish/error
30+
await client.close();
31+
}
32+
}
33+
run().catch(console.dir);
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// ignored first line
2+
const { MongoClient } = require("mongodb");
3+
4+
// specify the placeholder values for your environment in the following lines
5+
const username = encodeURIComponent("<username>");
6+
const password = encodeURIComponent("<password>");
7+
const clusterUrl = "<MongoDB cluster url>";
8+
9+
const authMechanism = "SCRAM-SHA-1";
10+
11+
// Replace the following with your MongoDB deployment's connection
12+
// string.
13+
const uri =
14+
`mongodb+srv://${username}:${password}@${clusterUrl}/?authMechanism=${authMechanism}`;
15+
16+
// Create a new MongoClient
17+
const client = new MongoClient(uri);
18+
19+
// Function to connect to the server
20+
async function run() {
21+
try {
22+
// Connect the client to the server
23+
await client.connect();
24+
25+
// Establish and verify connection
26+
await client.db("admin").command({ ping: 1 });
27+
console.log("Connected successfully to server");
28+
} finally {
29+
// Ensures that the client will close when you finish/error
30+
await client.close();
31+
}
32+
}
33+
run().catch(console.dir);
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// ignored first line
2+
const { MongoClient } = require("mongodb");
3+
4+
// specify the placeholder values for your environment in the following lines
5+
const username = encodeURIComponent("<username>");
6+
const password = encodeURIComponent("<password>");
7+
const clusterUrl = "<MongoDB cluster url>";
8+
9+
const authMechanism = "SCRAM-SHA-256";
10+
11+
// Replace the following with your MongoDB deployment's connection
12+
// string.
13+
const uri =
14+
`mongodb+srv://${username}:${password}@${clusterUrl}/?authMechanism=${authMechanism}`;
15+
16+
// Create a new MongoClient
17+
const client = new MongoClient(uri);
18+
19+
// Function to connect to the server
20+
async function run() {
21+
try {
22+
// Connect the client to the server
23+
await client.connect();
24+
25+
// Establish and verify connection
26+
await client.db("admin").command({ ping: 1 });
27+
console.log("Connected successfully to server");
28+
} finally {
29+
// Ensures that the client will close when you finish/error
30+
await client.close();
31+
}
32+
}
33+
run().catch(console.dir);
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// ignored first line
2+
const { MongoClient } = require("mongodb");
3+
const fs = require("fs");
4+
5+
const username = encodeURIComponent("<client certificate distinguished name>");
6+
const clusterUrl = "<MongoDB cluster url>";
7+
const clientPEMFile = encodeURIComponent(
8+
"<path to the client pem certificate file>",
9+
);
10+
const authMechanism = "MONGODB-X509";
11+
12+
// Replace the following with your MongoDB deployment's connection
13+
// string.
14+
const uri =
15+
`mongodb+srv://${username}@${clusterUrl}/?authMechanism=${authMechanism}&tls=true&tlsCertificateKeyFile=${clientPEMFile}`;
16+
17+
// Create a new MongoClient
18+
const client = new MongoClient(uri);
19+
20+
// Function to connect to the server
21+
async function run() {
22+
try {
23+
// Connect the client to the server
24+
await client.connect();
25+
26+
// Establish and verify connection
27+
await client.db("admin").command({ ping: 1 });
28+
console.log("Connected successfully to server");
29+
} finally {
30+
// Ensures that the client will close when you finish/error
31+
await client.close();
32+
}
33+
}
34+
run().catch(console.dir);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const { MongoClient } = require("mongodb");
2+
3+
// Connection URI
4+
const uri =
5+
"mongodb+srv://sample-hostname:27017/?poolSize=20&useUnifiedTopology=true";
6+
7+
// Create a new MongoClient
8+
const client = new MongoClient(uri);
9+
10+
async function run() {
11+
try {
12+
// Connect the client to the server
13+
await client.connect();
14+
15+
// Establish and verify connection
16+
await client.db("admin").command({ ping: 1 });
17+
console.log("Connected successfully to server");
18+
} finally {
19+
// Ensures that the client will close when you finish/error
20+
await client.close();
21+
}
22+
}
23+
run().catch(console.dir);

source/fundamentals.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ Fundamentals
55
.. default-domain:: mongodb
66

77
.. toctree::
8-
:caption: CRUD Operations
98

9+
/fundamentals/connection
1010
/fundamentals/crud
1111
/fundamentals/authentication
1212
/fundamentals/logging

source/fundamentals/authentication.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Overview
1515
These guides show you how to authenticate to a MongoDB instance using the
1616
Node.js driver.
1717

18-
The `Authentication Mechanisms <authentication-mechanisms>`_ guide contains
18+
The `Authentication Mechanisms <authentication/authentication-mechanisms>`_ guide contains
1919
sample connection code using each authentication mechanism supported in the
2020
MongoDB Community Edition which includes:
2121

@@ -26,7 +26,7 @@ MongoDB Community Edition which includes:
2626
- ``X.509``
2727

2828
The
29-
`Enterprise Authentication Mechanisms <authentication-mechanisms-enterprise>`_
29+
`Enterprise Authentication Mechanisms <authentication/authentication-mechanisms-enterprise>`_
3030
guide contains sample connection code using authentication mechanisms
3131
available only in MongoDB Enterprise Edition which includes:
3232

source/fundamentals/authentication/enterprise-mechanisms.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Enterprise Authentication Mechanisms
33
====================================
44

5-
In this section, you can find sample code for connection to MongoDB with each
5+
In this guide, you can find sample code for connection to MongoDB with each
66
authentication mechanism available in the MongoDB Enterprise Edition:
77
``Kerberos (GSSAPI/SSPI)`` and ``LDAP (PLAIN)``.
88

0 commit comments

Comments
 (0)