Skip to content

Commit cf548ea

Browse files
committed
NODE-570 added documentation for DEFAULT authentication method
1 parent 2ba67a7 commit cf548ea

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

docs/reference/content/reference/connecting/authenticating.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,26 @@ MongoDB 3.0 changed the default authentication mechanism from
1919
[SCRAM-SHA-1](http://docs.mongodb.org/manual/core/authentication/#scram-sha-1-authentication).
2020
{{% /note %}}
2121

22+
## DEFAULT
23+
24+
If no authentication mechanism is specified or the mechanism DEFAULT is specified, the driver will attempt to authenticate using the SCRAM-SHA-1 authentication method if it is available on the MongoDB server. If the server does not support SCRAM-SHA-1 the driver will authenticate using MONGODB-CR.
25+
26+
```js
27+
var MongoClient = require('mongodb').MongoClient,
28+
f = require('util').format,
29+
assert = require('assert');
30+
31+
// Connection URL
32+
var url = 'mongodb://dave:password@localhost:27017?authMechanism=DEFAULT&authSource=db';
33+
// Use connect method to connect to the Server
34+
MongoClient.connect(url, function(err, db) {
35+
assert.equal(null, err);
36+
console.log("Connected correctly to server");
37+
38+
db.close();
39+
});
40+
```
41+
2242
## SCRAM-SHA-1
2343

2444
To explicitly connect to MongoDB using [SCRAM-SHA-1](http://docs.mongodb .org/manual/core/authentication/#scram-sha-1-authentication), we pass the following parameters to the driver over the connection URI.

0 commit comments

Comments
 (0)