File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -66,19 +66,20 @@ Delegated Authentication
66
66
------------------------
67
67
.. versionadded: 2.5
68
68
69
- In MongoDB 2.4.x a separate authentication source can be specified.
70
- This feature was introduced in MongoDB 2.4 and removed in 2.6::
69
+ If your user is defined in one database with a role that gives it
70
+ authorization on a different database use the `source ` option to specify
71
+ the database in which the user is defined::
71
72
72
73
>>> from pymongo import MongoClient
73
74
>>> client = MongoClient('example.com')
74
- >>> client.the_database.authenticate('user',
75
- ... 'password',
76
- ... source='source_database')
75
+ >>> db = client.the_database
76
+ >>> db.authenticate('user', 'password', source='source_database')
77
77
True
78
- >>>
78
+
79
+ Or the `authSource ` URI option::
80
+
79
81
>>> uri = "mongodb://user:password@example.com/?authSource=source_database"
80
- >>> client = MongoClient(uri)
81
- >>>
82
+ >>> db = MongoClient(uri).the_database
82
83
83
84
MONGODB-X509
84
85
------------
You can’t perform that action at this time.
0 commit comments