edelight / chef-mongodb

MongoDB Chef cookbook
https://community.opscode.com/cookbooks/mongodb
Apache License 2.0
362 stars 3 forks source link

User management support one user any databases? #392

Open supergrilo opened 9 years ago

supergrilo commented 9 years ago

The user_management recipe can support create an user to use many databases? something like that

use reporting
db.createUser(
    {
      user: "reportsUser",
      pwd: "12345678",
      roles: [
         { role: "read", db: "reporting" },
         { role: "read", db: "products" },
         { role: "read", db: "sales" },
         { role: "readWrite", db: "accounts" }
      ]
    }
)
supergrilo commented 9 years ago

@jamesonjlee can you help?

ballerabdude commented 9 years ago

@supergrilo This cook book will install version 2.4.9 of the mongo shell. Version 3 started supporting creating users the way you are creating it. In your version you have to do it this way

use reporting
db.addUser( { user: "reportsUser",
              pwd: "12345678",
              roles: [ "read" ]
            } )

You have to do this for every database. This cookbook is out of date use this one they maybe taking it over https://github.com/chef-brigade/mongodb-cookbook. Here is more info on adding a user with your version http://docs.mongodb.org/v2.4/tutorial/add-user-to-database/.

supergrilo commented 9 years ago

@ballerabdude this way works on 2.x mongod.

If you need allow user to siwtch between databases, in the same connection session, you need to do this auth configuration in the same database.

maybe turn this issue a feature request?