Details
-
Improvement
-
Resolution: Done
-
Blocker - P1
-
None
-
*Location*: http://docs.mongodb.org/manual/tutorial/add-user-to-database/
*User-Agent*: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0 IKDhPmJcdw
*Referrer*: http://www.google.de/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&ved=0CEYQFjAB&url=http%3A%2F%2Fdocs.mongodb.org%2Fmanual%2Ftutorial%2Fadd-user-to-database&ei=CR4HVPysH-HJ0QX8t4GoDg&usg=AFQjCNFddqbbnggCky_ZTVNh4nB4Y9XTxA&sig2=aG1parIbWjD53MGtFGpsFA&bvm=bv.74115972,d.bGQ&cad=rja
*Screen Resolution*: 1680 x 1050
*repo*: docs
*source*: tutorial/add-user-to-database
*Location*: http://docs.mongodb.org/manual/tutorial/add-user-to-database/ *User-Agent*: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0 IKDhPmJcdw *Referrer*: http://www.google.de/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&ved=0CEYQFjAB&url=http%3A%2F%2Fdocs.mongodb.org%2Fmanual%2Ftutorial%2Fadd-user-to-database&ei=CR4HVPysH-HJ0QX8t4GoDg&usg=AFQjCNFddqbbnggCky_ZTVNh4nB4Y9XTxA&sig2=aG1parIbWjD53MGtFGpsFA&bvm=bv.74115972,d.bGQ&cad=rja *Screen Resolution*: 1680 x 1050 *repo*: docs *source*: tutorial/add-user-to-database
Description
When adding a user to multiple databases, use unique username-and-password combinations for each database
While this sentence is true for itself, it may lead to the conclusion that a user who needs to access different databases has to be added to each database individually.
However, it's recommended to add such an user only once by giving him/her multiple roles for all the databases he/she needs to access.
For example:
{
|
_id: "home.Kari",
|
user: "Kari",
|
db: "home",
|
credentials: { "MONGODB-CR" :"<hashed password>" },
|
roles : [
|
{ role: "read", db: "home" },
|
{ role: "readWrite", db: "test" },
|
{ role: "appUser", db: "myApp" }
|
],
|
customData: { zipCode: "64157" }
|
}
|
This user has been added only once to the home database having access to the three databases home, test and myApp.
See: http://docs.mongodb.org/manual/reference/system-users-collection/